Heredoc Formatting
…a way to define a multiline string, while maintaining the original indentation & formatting.
So, it is somewhat ironic that we also have "ActionMailer::MailHelper#block_format to clean up poorly formatted text", as RubyCademy shared on TwiXter (be sure to view their example at the link). The documentation specifies that this method will:
Take the text and format it, indented two spaces for each line, and wrapped at 72 columns:
And they provide the following example:
text = <<-TEXT This is the paragraph. * item1 * item2 TEXT block_format text # => " This is the paragraph.\n\n * item1\n * item2\n"
What RubyCademy failed to mention is the part about indenting every line by two spaces, which may not be what you want. Also, since heredocs are intended to "[maintain] the original indentation & formatting", it seems weird that you would want to undo the existing formatting. Perhaps you are importing the text from somewhere?
Either way, this is a fine example of why it's important to know what your methods are doing before you use them. Or, at the very least, consult the documentation when things don't come out as you expected.