shreeve / s2s.org (Steve Shreeve) writes:

> 1) It leaves leaves my code looking very ugly, with the terminators not 
> indented properly, as in:

In Ruby, you can indent the terminator if you precede the original
with a minus sign:

    str = <<-END
    This is
    the
    END

> 2) Also, I like to indent the actual HTML so my program is more readable, but 
> when I do this, the generated HTML has a bunch of leading whitespace which can 
> sometimes even cause problems... uck! To prevent the leading whitespace 
> problem, I usually do this:

You could do a similar thing in Ruby without munging the source. For
example, you could define a method "tidy" which stripped all leading
whitespace:

    def tidy(str)
      str.gsub(/^\s+/s, '')
    end

And then call it using

    str = tidy <<-END
    This is
    the
    END

Or you could make it a method of class String:

    class String
      def tidy
        gsub(/^\s+/s, '')
      end
    end

And then call it using

    str = <<-END.tidy
    This is
    the
    END



Of course, you can then develop tidy further to honor indentation
within the block and so on.


Regards


Dave