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
例 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:" "}

OUTPUT:

Grandmother of
eight makes        hole in one.
Grandmother of eight makes hole in one.
Grandmother of eight makes hole in one.