Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 50 additions & 3 deletions Documentation/Global/Format/Nl2br.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
.. Source: https://github.com/TYPO3/Fluid/blob/main/src/ViewHelpers/Format/Nl2brViewHelper.php

:edit-on-github-link: https://github.com/TYPO3/Fluid/edit/main/src/ViewHelpers/Format/Nl2brViewHelper.php
:navigation-title: format.nl2br

.. include:: /Includes.rst.txt
Expand All @@ -13,3 +10,53 @@ Format.nl2br ViewHelper `<f:format.nl2br>`

.. typo3:viewhelper:: format.nl2br
:source: ../../Global.json
:display: tags,description,gitHubLink
:noindex:

.. contents:: Table of contents

.. _typo3-fluid-format-nl2br-example:

Preserving line breaks in HTML output
=====================================

HTML ignores line breaks within text. To display text while preserving line
breaks, you must convert newline characters such as `\\n` or `\\r\\n` into
HTML line break elements :html:`<br />`.

The `<f:format.nl2br>` ViewHelper uses PHP's
`nl2br() <https://www.php.net/manual/en/function.nl2br.php>`_ function
to insert HTML line breaks.

.. code-block:: plaintext
:caption: User input

This is
a
string

.. code-block:: html

<f:format.nl2br>{userInput}</f:format.nl2br>

or inline:

.. code-block:: html

{userInput -> f:format.nl2br()}

.. code-block:: html
:caption: Output

This is<br />
a<br />
string

.. _typo3-fluid-format-nl2br-arguments:

Arguments of the `<f:format.nl2br>` ViewHelper
==============================================

.. typo3:viewhelper:: format.nl2br
:source: ../../Global.json
:display: arguments-only