Today I Learned

hashrocket A Hashrocket project

Multiline strings in YAML

If you're using Middleman data files (which are awesome), you might run into an issue where you want to store text intended for Markdown processing within a .yaml file. To do so, just use |:

  content: |
    # This is some markdown content in YAML that will be output as an <h1>.

    This will be output as a paragraph tag.

    So will this!

Technically you can use > instead of |, but > does not output linebreaks when the YAML is parsed, which can create issues when the text is processed through Markdown.

See More #ruby TILs
Looking for help? Each developer at Hashrocket has years of experience working with Ruby applications of all types and sizes. We're an active presence at Ruby conferences, have written some of the most popular gems, and have worked on many of the web's Ruby on Rails success stories. Contact us today to talk about your Ruby project.