From: Avdi Grimm Date: 2013-11-13T20:40:04-05:00 Subject: [ruby-core:58322] Re: [ruby-trunk - Feature #9098][Open] Indent heredoc against the left margin by default when "indented closing identifier" is turned on. --047d7b34364e600f0304eb192ad8 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On Sat, Nov 9, 2013 at 4:18 PM, sikachu (Prem Sichanugrist) wrote: I've been using here document (heredoc) for a while, and I've found out > that it's very annoying that the content is always treated as flushed lef= t. This has actually bugged me for a very long time. Other languages have triple-quoted strings where the indent of the opening triple-quote is taken into account, and automatically stripped from the resulting text. In Ruby if I don=92t want leading spaces I have to break the visual flow of my indentation (or resort to something like #strip_heredoc). I don=92t agree with changing the existing heredocs to have new semantics. But I could see adding e.g. a "squiggly-heredoc": class Foo BAR =3D <<~EOF This line is cleanly indented EOFend Foo::BAR # =3D> "This line is\ncleanly indented" Note that the way I imagine it, this would work a little different than triple-quoted strings in other languages, since the indentation wouldn=92t = be determined by the location of the opening signifier. Instead, it would be determined by indentation of the first non-whitespace character inside the heredoc. --=20 Avdi Grimm http://avdi.org I only check email twice a day. to reach me sooner, go to http://awayfind.com/avdi --047d7b34364e600f0304eb192ad8 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable

On Sat, Nov 9, 2013 at 4:18 PM, sikachu (Prem S= ichanugrist) <s@sikac.hu> wrote:

I've been using here document (heredoc)= for a while, and I've found out that it's very annoying that the c= ontent is always treated as flushed left.

This has actually bugged me for a very long tim= e. Other languages have triple-quoted strings where the indent of the openi= ng triple-quote is taken into account, and automatically stripped from the = resulting text. In Ruby if I don=92t want leading spaces I have to break th= e visual flow of my indentation (or resort to something like #strip_heredoc= ).

I don=92t agree with changing the existing here= docs to have new semantics. But I could see adding e.g. a "squiggly-he= redoc":

class Foo
  BAR =3D <<~EOF
  This line is
  cleanly indented
  EOF
end<=
/span>

Foo::BAR # =3D> "This line is\nclea=
nly indented"

Note that the way I imagine it, this would work= a little different than triple-quoted strings in other languages, since th= e indentation wouldn=92t be determined by the location of the opening signi= fier. Instead, it would be determined by indentation of the first non-white= space character inside the heredoc.

--
Avdi Grimm
http://avdi.org

I only check email twic= e a day. to reach me sooner, go to http://awayfind.com/avdi
--047d7b34364e600f0304eb192ad8--