Today I Learned

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 |:

widget:
  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.

Looking for help? Each developer at Hashrocket has years of experience working with Ruby applications of all types and sizes. Contact us and find out how we can help you.