strip

转换连续空格,回车和tab到单个空格或是指定字符串。

说明

如果你希望转换模板文字内的空格,使用内置的 {strip} 函数。


Example 5.19. strip

  1. <?php
  2. $smarty->assign('articleTitle', "Grandmother of\neight makes\t hole in one.");
  3. $smarty->display('index.tpl');
  4. ?>
  5.  

模板:

  1. {$articleTitle}
  2. {$articleTitle|strip}
  3. {$articleTitle|strip:'&nbsp;'}
  4.  

输出:

  1. Grandmother of
  2. eight makes hole in one.
  3. Grandmother of eight makes hole in one.
  4. Grandmother&nbsp;of&nbsp;eight&nbsp;makes&nbsp;hole&nbsp;in&nbsp;one.
  5.  

参见 {strip}truncate.

原文: https://www.smarty.net/docs/zh_CN/language.modifier.strip.tpl