Format.html ViewHelper <f:format.html>
Renders a string by passing it to a TYPO3 parseFunc.
You can either specify a path to the TypoScript setting or set the parseFunc options directly.
By default lib.
is used to parse the string.
The view helper must not be used in backend context, as it triggers frontend logic.
Instead, use <f:
to secure a given HTML string or <f:
to parse links in HTML.
Examples
Default parameters
<f:format.html>{$myConstant.project} is a cool <b>CMS</b> (<a href="https://www.typo3.org">TYPO3</a>).</f:format.html>
Output:
<p class="bodytext">TYPO3 is a cool <strong>CMS</strong> (<a href="https://www.typo3.org" target="_blank">TYPO3</a>).</p>
Depending on TYPO3 constants.
Custom parseFunc
<f:format.html parseFuncTSPath="lib.parseFunc">TYPO3 is a cool <b>CMS</b> (<a href="https://www.typo3.org">TYPO3</a>).</f:format.html>
Output:
TYPO3 is a cool <strong>CMS</strong> (<a href="https://www.typo3.org" target="_blank">TYPO3</a>).
Data argument
If you work with TypoScript field
property, you should add the current record as data
to the ViewHelper to allow processing the field
and data
properties correctly.
<f:format.html data="{newsRecord}" parseFuncTSPath="lib.news">News title: </f:format.html>
After "dataWrap = |<strong>{FIELD:title}</strong>" you may have this Output:
News title: <strong>TYPO3, greatest CMS ever</strong>
Current argument
Use the current
argument to set the current value of the content object.
<f:format.html current="{strContent}" parseFuncTSPath="lib.info">I'm gone</f:format.html>
After set
you may have this output:
Thanks Kasper for this great CMS
CurrentValueKey argument
Use the current
argument to define a value of data object as the current value.
<f:format.html data="{contentRecord}" currentValueKey="header" parseFuncTSPath="lib.content">Content: </f:format.html>
After data
you may have this Output:
Content: How to install TYPO3 in under 2 minutes ;-)
Inline notation
{someText -> f:format.html(parseFuncTSPath: 'lib.parseFunc')}
Output:
TYPO3 is a cool <strong>CMS</strong> (<a href="https://www.typo3.org" target="_blank">TYPO3</a>).
Source code
Go to the source code of this ViewHelper: Format\HtmlViewHelper.php (GitHub).
Arguments
The following arguments are available for the format.html ViewHelper:
current
-
- Type
- string
Initialize the content object with this value for current property.
currentValueKey
-
- Type
- string
Define the value key, used to locate the current value for the content object
data
-
- Type
- mixed
Initialize the content object with this set of data. Either an array or object.
parseFuncTSPath
-
- Type
- string
- Default
- 'lib.parseFunc_RTE'
Path to the TypoScript parseFunc setup.
table
-
- Type
- string
- Default
- ''
The table name associated with the "data" argument.