Scott Watermasysk Husband, Father, Bootstrapper, Developer, Keyboarder, Pained Sixers Fan.

Squiggly Heredoc

Published:

Continuing the trend of things that existed for years in Ruby without my knowledge...

Heredocs have often had weird formatting due to leading white spaces. Active Support has a helper method strip_heredoc, but since Ruby 2.3, you can use the squiggly ‘~’ instead.

Before:

<<-DOC
DOC

But now you can do:

<<~DOC
DOC

I have been trying to be more cognizant of dependencies. Seems trivial, but this solved a big problem with my Jekyll Rest project and did not require another dependency.