Skip to content

Instantly share code, notes, and snippets.

@shinzui
Forked from mtodd/gist:180398
Created September 13, 2009 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinzui/186248 to your computer and use it in GitHub Desktop.
Save shinzui/186248 to your computer and use it in GitHub Desktop.
Surround a heredoc with quotes and you can continue the code on the same line:
render :status => 404, :text => <<-'EOH' and return unless setup
article not found<br/>
I, as a server, have failed<br/>
https?
EOH
Quotes also give you more freedom/creativity with the terminal ID:
eval <<-"end;"
def #{foo}
bar
end
end;
Also, you can include multiple Heredocs on the same line:
puts <<-"end:foo", <<-"end:bar"
This is the first chunk to be printed,
and is separate than the Bar group.
Foo!
end:foo
This is logically separate from the foo group.
There's nothing special about the identifiers,
they just are more appropriately named.
end:bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment