Edit on GitHub
Jump to docs navigation

Twig Components / Methods / nl2br

Note: You are currently reading the documentation for Bolt 5.0. Looking for the documentation for Bolt 5.2 instead?

nl2br(is_xhtml) is a Twig filter to insert HTML line breaks before all newlines in a string:

{{ "I like Twig.\nYou will like it too."|nl2br }}
{# outputs

    I like Twig.<br />
    You will like it too.

#}

NoteΒΆ

The nl2br filter pre-escapes the input before applying the transformation.

Source: Twig



Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.