HBcms是一个用Pear框架+Smarty模板引擎构架的cms项目,欢迎大家参与制作Smarty模板

nl2br
换行符替换成
<br />


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

所有的换行符将被替换成 <br />.功能同PHP中的nl2br()函数一样.

Example 5-14. nl2br
Smarty手册范例 5-14.换行符替换成<br />

index.php:

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

index.tpl:

{$articleTitle|nl2br}

输出结果:

Sun or rain expected<br />today, dark tonight
这是一份简单的Smarty手册和Smarty教材,熟练掌握Smarty模板,让您做项目事半功倍