From: Andrew Johnson Date: 2004-10-03T17:50:01+09:00 Subject: Re: Feature Request: Truly Indented Here-Docs On Sun, 3 Oct 2004 12:55:51 +0900, James Edward Gray II wrote: [snip] > It would make a lot more sense to me if lines of a here-doc were > stripped of leading whitespace equal to the indention of the end tag. > Is there any reason this wasn't done, or isn't practical? I usually give my here-docs a block-like structure: str = <<-DOC line 1 line 2 DOC so stripping leading spaces equal to indentation of the terminator-tag wouldn't be my preference. I've found the following useful for stripping common leading space: class String def dedent a = $1 if match(/\A(\s*)(.*\n)(?:\1.*\n|\n)*\z/) gsub(/^#{a}/, '') end end # then later: puts <<-DOC.dedent * item 1 * item 1.2 * item 2 * item 2.1 DOC andrew