Smarty 图标

根据商标声明,您可以使用 Smarty 徽标。

Smarty Template Engine Smarty Template Engine

对于赞助、广告、新闻或其他询问,请联系我们

使用 Smarty 的网站

广告

{textformat}

{textformat} 是用于格式化文本的块函数。它可以清除空格和特殊字符,并且通过换行和缩进的方式来格式化段落。

您可以明确设置参数,或使用预置样式。目前,“email”是唯一可用的样式。

属性名称 类型 必填 默认值 描述
样式 字符串 n/a 预置样式
缩进 数字 0 每行缩进的字符数
首行缩进 数字 0 首行缩进的字符数
缩进字符 字符串 (单个空格) 缩进的字符(或字符串)
换行 数字 80 每行换多少个字符
换行字符 字符串 \n 用此字符(或字符串)换行
截断换行 布尔值 FALSE 如果为 TRUE,则换行将在确切的字符处截断,而不是按单词边界截断
分配 字符串 n/a 输出分配给的模板变量

示例 8.22 {textformat}

   {textformat wrap=40}

   This is foo.
   This is foo.
   This is foo.
   This is foo.
   This is foo.
   This is foo.

   This is bar.

   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.

   {/textformat}


  

以上示例将输出


   This is foo. This is foo. This is foo.
   This is foo. This is foo. This is foo.

   This is bar.

   bar foo bar foo foo. bar foo bar foo
   foo. bar foo bar foo foo. bar foo bar
   foo foo. bar foo bar foo foo. bar foo
   bar foo foo. bar foo bar foo foo.

  
   {textformat wrap=40 indent=4}

   This is foo.
   This is foo.
   This is foo.
   This is foo.
   This is foo.
   This is foo.

   This is bar.

   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.

   {/textformat}


  

以上示例将输出


   This is foo. This is foo. This is
   foo. This is foo. This is foo. This
   is foo.

   This is bar.

   bar foo bar foo foo. bar foo bar foo
   foo. bar foo bar foo foo. bar foo
   bar foo foo. bar foo bar foo foo.
   bar foo bar foo foo. bar foo bar
   foo foo.

  
   {textformat wrap=40 indent=4 indent_first=4}

   This is foo.
   This is foo.
   This is foo.
   This is foo.
   This is foo.
   This is foo.

   This is bar.

   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.

   {/textformat}

  

以上示例将输出


   This is foo. This is foo. This
   is foo. This is foo. This is foo.
   This is foo.

   This is bar.

   bar foo bar foo foo. bar foo bar
   foo foo. bar foo bar foo foo. bar
   foo bar foo foo. bar foo bar foo
   foo. bar foo bar foo foo. bar foo
   bar foo foo.

  
   {textformat style="email"}

   This is foo.
   This is foo.
   This is foo.
   This is foo.
   This is foo.
   This is foo.

   This is bar.

   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.
   bar foo bar foo     foo.

   {/textformat}


  

以上示例将输出


   This is foo. This is foo. This is foo. This is foo. This is foo. This is
   foo.

   This is bar.

   bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo
   bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo
   foo.


  

另请参阅 {strip}wordwrap