In my messages.en.yml
I have an entry that is used for an email body which is in plaintext, so I cannot use any HTML tags. Now when I need a line break and I add a blank line after, the line break appears in my email body.
But when I try to do a line break with a non empty line following, it does not break the lines.
email:
subject: My Subject
message: >
Hello %name%,
This is my second line
Best regards,
John Smith
Customer Care
Arrives like this in my mailbox
Hello Tom,
This is my second line
Best regards, John Smith Customer Care
I've tried to play around with HTML tags or with the \n
which I know from PHP. But if I use <br>
or <br />
in the translation file and apply the |raw
filter in my twig file, the HTML tags still appear in my email body. And also if I use \n
to force a line break, no line break is given and instead, the \n
appear in my email as well.
Now how can I force the line break if a non empty line is following?
Use |
email:
subject: My Subject
message: |
Hello %name%,
This is my second line
Best regards,
John Smith
Customer Care
In your translations file (e.g. messages.en.yml
):
your
translation
key:
here: |
Lorem ipsum.
CRMPICCO.
www.crmpicco.co.uk.
Accessing it in your Twig template:
{{ 'your.translation.key.here'|trans|nl2br }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With