I'm not convinced yet this belongs in Ruby.
The only argument I have heard for this is because 'left shifting' a block
of text 'looks bad'.
However, the solution looks even worse.

If a programmer doesn't like the left shift, put the text in a file of it's
own or put it in DATA.

Does anyone else agree? Does anyone have a better reason to spend time on
this?

Jim


On Tue, Oct 4, 2011 at 1:21 AM, Trans <transfire / gmail.com> wrote:

> On Tue, Oct 4, 2011 at 1:21 AM, "Martin J. D=FCrst"
> <duerst / it.aoyama.ac.jp> wrote:
> >
> >
> > On 2011/10/03 22:27, Nikolai Weibull wrote:
> >>
> >> On Mon, Oct 3, 2011 at 14:16, Yusuke Endoh<mame / tsg.ne.jp>  wrote:
> >
> >>> How about importing String#margin from Facets?
> >>>
> >>>  my_string =3D<<-END.margin
> >>>    |doc
> >>>    |doc
> >>>    |doc
> >>>  END
> >>
> >> Why not implement it by checking the amount of leading whitespace on
> >> the first line and strip that amount of whitespace from all subsequent
> >> lines?
> >
> > Yes, something like that seems much more desirable.
>
> That's essentially what #tabto does. It keeps relative spacing based
> on the first line and optionally adds `n` spaces of indention.
>
> > Examples such as
> >
> >  x =3D %Q{
> >        |This
> >        |  is
> >        |    margin controlled!
> >        }.margin
> >
> > (from http://trans.github.com/string/ruby/2011/10/02/string-iou.html)
> look
> > cute, but if the data is actually something like HTML or any other
> > kind of structured stuff (or even Ruby, if used for code generation), w=
ho
> > wants to see all the '|' bars? I'd guess just about nobody.
>
> The #margin method was written to emulate literal syntax %L. It not
> that anyone wants to see the '|' (or whatever character one chooses),
> rather it is that it allows for a literal representation of the
> multi-line string, whitespace and all.
>
>


--=20
Jim Freeze