I am trying to keep newlines in a yaml file. In a messages.en.yml file, I have.
test:|
Here is line 1
Here is line 2
And in form.html.twig:
{{'test'|trans}}Both lines are rendered on the same line. Here is line 1 Here is line 2
In this link, the literal style for Yaml is explained. and in this other one, it says "Notable lacking features are: document directives, multi-line quoted messages ..."
So is it possible in Symfony Yaml to use multilines? and how?
You could use |nl2br
filter
{{ 'test'|trans|nl2br }}
Or, if you are sure your translation can't get altered by any user, you could use some few html in your translation.
test:|
Here is line 1<br/>
Here is line 2<br/>
<br/><br/>
Here is line 5
Then
{{ 'test'|trans|raw }}