nl2br

All linebreaks will be converted to <br /> tags in the given variable. This is equivalent to the PHP nl2br() function.

Example 5-14. nl2br

index.php:

$smarty = new Smarty;
$smarty->assign('articleTitle', "Sun or rain expected\ntoday, dark tonight");
$smarty->display('index.tpl');

index.tpl:

{$articleTitle|nl2br}

OUTPUT:

Sun or rain expected<br />today, dark tonight