Files
smarty/docs/designers/language-modifiers/language-modifier-nl2br.md

38 lines
682 B
Markdown
Raw Permalink Normal View History

2023-02-06 14:42:31 +01:00
# nl2br
All `"\n"` line breaks will be converted to html `<br />` tags in the
given variable. This is equivalent to the PHP\'s
2023-02-03 22:31:59 +01:00
[`nl2br()`](https://www.php.net/nl2br) function.
2023-02-06 14:42:31 +01:00
## Basic usage
```smarty
{$myVar|nl2br}
```
2023-02-06 14:42:31 +01:00
## Examples
2023-02-06 14:42:31 +01:00
```php
<?php
2023-02-06 14:42:31 +01:00
$smarty->assign('articleTitle',
"Sun or rain expected\ntoday, dark tonight"
);
2023-02-06 14:42:31 +01:00
```
Where the template is:
2023-02-06 14:42:31 +01:00
```smarty
{$articleTitle|nl2br}
```
Will output:
2023-02-06 14:42:31 +01:00
```
Sun or rain expected<br />today, dark tonight
```
2023-02-06 14:42:31 +01:00
See also [`word_wrap`](language-modifier-wordwrap.md),
[`count_paragraphs`](language-modifier-count-paragraphs.md) and
[`count_sentences`](language-modifier-count-sentences.md).