pinnacol / linecook

A shell script generator.
Other
9 stars 1 forks source link

indent will mess up heredocs #3

Closed thinkerbot closed 13 years ago

thinkerbot commented 13 years ago

For example:

[recipe/example.rb]
target.puts "# outdent"
indent do
  target.puts "# indent"
  heredoc do
    target.puts 'abc'
    target.puts 'xyz'
  end
end
target.puts "# outdent"

Produces:

# outdent
  # indent
  << HEREDOC_0
  abc
  xyz
  HEREDOC_0
# outdent

To solve this, perhaps add magic comments to turn on/off indent, a-la

    << HEREDOC_0 # :indent-off:
  abc
  xyz
  HEREDOC_0  # :indent-on:

Then strip out these processing instructions within indent if capture depth is 0 (ie right before the indent is written to the true output).

thinkerbot commented 13 years ago

Indent logic is now in linebook. Closed by pinnacol/linebook@23fccaed9fb5bfa39c9400b6a940b184b8f6bb70