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

strip
去除(多余空格)

This replaces all repeated spaces, newlines and tabs with a single space, or with a supplied string.

用一个空格或一个给定字符替换所有重复空格,换行和制表符.

Note: If you want to strip blocks of template text, use the strip function.

注意:如果想要去除模板文本中的区块,请使用 strip函数

Example 5-19. strip
Smarty手册范例 5-19.去除(多余空格)

index.php:

$smarty = new Smarty;
$smarty->assign('articleTitle', "Grandmother of\neight makes\t hole in one.");
$smarty->display('index.tpl');

index.tpl:

{$articleTitle}
{$articleTitle|strip}
{$articleTitle|strip:" "}

输出结果:

Grandmother of
eight makes hole in one.
Grandmother of eight makes hole in one.
Grandmother of eight makes hole in one.
这是一份简单的Smarty手册和Smarty教材,熟练掌握Smarty模板,让您做项目事半功倍