Format body text from YAML

I, essentially, have some body text in a YAML file that i want to pull out into a certain page. Often this text is multiple paragraphs. I’m wondering what the best way to preserve the line-break formatting would be. I basically want to have ‘p’ tags wrapped around each paragraph.

Would just adding those tags into said text be best?

Hi @brad,

You have a couple of different options. One is to use the simple_format helper, which will format your paragraphs.

Inside your page:

---
about:
  Hello there. Here's some content in pure YAML.

  It has paragraphs.
---

<%= simple_format current_page.data.about %>

Alternatively, you could access a Tilt template renderer directly. This is a bit more low-level, and might have some unintended side-effects. See the Tilt documentation for more information.

Inside config.rb:

def markdown(content)
   Tilt['markdown'].new { content }.render
end

Inside your page:

---
about:
  Hello there. Here's some content in pure YAML.

  It has paragraphs.
---

<%= markdown current_page.data.about %>