Last Updated: February 25, 2016
· blahed

Heredocs with leading whitespace removed

Handy if you like to keep things indented.

def initialize
    @foo = <<-EOF.gsub /^\s+/, ""
        This will not be indented in the resulting string

And a few other clever ways to handle it:

2 Responses
Add your response

If you're using rails, just use strip_heredoc:

over 1 year ago ·

Yup, and it handles keeping "real" indentions.

over 1 year ago ·