Multi-line strings in frontmatter?

I have a few items in my frontmatter which have long descriptions. I’d like to add line breaks to the descriptions instead of it being one long string. How is this done? Adding
works but it’s a pretty hacky way to do it.

I’ve been looking to the YAML way to do it (link here) and apparently it should be done like so:

description: |   
   here's a loong description    
   which spans multiple lines   

However, this doesn’t work in Grav. What’s the Grav way to do it?

To be honest i’m not sure. If it doesn’t work then it’s an issue with the Symfony YAML parser: https://github.com/symfony/symfony/issues/12095 (maybe this issue?)

You could try installing the PECL yaml parser, as that will automatically get used in place of the Symfony YAML parser if found.

Guess I’ll have to try that. It might be the parser. Whenever I save the document, this…

    description: |
         here's a looong description
         which spans multiple lines
         third line here

… turns into this:

   description: "here's a looong description /nwhich spans multiple lines /nthird line here"

There’s an /n appearing wherever a line break is supposed to be when the page is reloaded or saved. That must mean that the parser is to blame?

To clarify, what I meant was that the /n is a line break so that’s correct, but the parser isn’t parsing it into a new line for some reason in the front-end.

Hi @dimis,

I think the multiline string is working, but the problem lies on the Twig end how you print out the variable. By default web browsers are whitespace/newlines agnostic, meaning you have to convert all line breaks into their corresponding markup (here: <br>, see http://twig.sensiolabs.org/doc/filters/nl2br.html ). Thus the Twig one liner should do the job

{{ page.header.description|nl2br }}

Best,
Sommerregen