1- .. Source: https://github.com/TYPO3/Fluid/blob/main/src/ViewHelpers/Format/Nl2brViewHelper.php
2-
3- :edit-on-github-link: https://github.com/TYPO3/Fluid/edit/main/src/ViewHelpers/Format/Nl2brViewHelper.php
41:navigation-title: format.nl2br
52
63.. include :: /Includes.rst.txt
@@ -13,3 +10,53 @@ Format.nl2br ViewHelper `<f:format.nl2br>`
1310
1411.. typo3 :viewhelper :: format.nl2br
1512 :source: ../../Global.json
13+ :display: tags,description,gitHubLink
14+ :noindex:
15+
16+ .. contents :: Table of contents
17+
18+ .. _typo3-fluid-format-nl2br-example :
19+
20+ Preserving line breaks in HTML output
21+ =====================================
22+
23+ HTML ignores line breaks within text. To display text while preserving line
24+ breaks, you must convert newline characters such as `\\n ` or `\\r\\n ` into
25+ HTML line break elements :html: `<br />`.
26+
27+ The `<f:format.nl2br> ` ViewHelper uses PHP's
28+ `nl2br() <https://www.php.net/manual/en/function.nl2br.php >`_ function
29+ to insert HTML line breaks.
30+
31+ .. code-block :: plaintext
32+ :caption: User input
33+
34+ This is
35+ a
36+ string
37+
38+ .. code-block :: html
39+
40+ <f:format .nl2br >{userInput}</f:format .nl2br >
41+
42+ or inline:
43+
44+ .. code-block :: html
45+
46+ {userInput -> f:format.nl2br()}
47+
48+ .. code-block :: html
49+ :caption: Output
50+
51+ This is<br />
52+ a<br />
53+ string
54+
55+ .. _typo3-fluid-format-nl2br-arguments :
56+
57+ Arguments of the `<f:format.nl2br> ` ViewHelper
58+ ==============================================
59+
60+ .. typo3 :viewhelper :: format.nl2br
61+ :source: ../../Global.json
62+ :display: arguments-only
0 commit comments