[TASK] Sync CMS Fluid with Flow Fluid 1.1 (part1)
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Format / Nl2brViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Format;
3
4 /* *
5 * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6 * *
7 * It is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU Lesser General Public License, either version 3 *
9 * of the License, or (at your option) any later version. *
10 * *
11 * The TYPO3 project - inspiring people to share! *
12 * */
13
14 /**
15 * Wrapper for PHPs nl2br function.
16 * @see http://www.php.net/manual/en/function.nl2br.php
17 *
18 * = Examples =
19 *
20 * <code title="Example">
21 * <f:format.nl2br>{text_with_linebreaks}</f:format.nl2br>
22 * </code>
23 * <output>
24 * text with line breaks replaced by <br />
25 * </output>
26 *
27 * <code title="Inline notation">
28 * {text_with_linebreaks -> f:format.nl2br()}
29 * </code>
30 * <output>
31 * text with line breaks replaced by <br />
32 * </output>
33 *
34 * @api
35 */
36 class Nl2brViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
37
38 /**
39 * Replaces newline characters by HTML line breaks.
40 *
41 * @return string the altered string.
42 * @api
43 */
44 public function render() {
45 $content = $this->renderChildren();
46 return nl2br($content);
47 }
48 }
49
50 ?>