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

textformat

Attribute Name Type Required Default Description
style string No n/a preset style
indent number No 0 The number of chars to indent every line
indent_first number No 0 The number of chars to indent the first line
indent_char string No (single space) The character (or string of chars) to indent with
wrap number No 80 How many characters to wrap each line to
wrap_char string No \n The character (or string of chars) to break each line with
wrap_cut boolean No false If true, wrap will break the line at the exact character instead of at a word boundary
assign string No n/a the template variable the output will be assigned to

属性 类型 是否必须 缺省值 描述
style string No n/a 预处理风格
indent number No 0 单行缩进的字符数目
indent_first number No 0 首行缩进的字符数目
indent_char string No (single space) 填充缩进区域的字符(或字符串)
wrap number No 80 单行长度,超过该长度自动折行
wrap_char string No \n 折行使用的字符(或字符串),被附加在行尾
wrap_cut boolean No false 如果设置为真,换行时不考虑换行点所在位置是否为完整单词,直接换行. 反之将在单词的边界处换行.
assign string No n/a 输出值将被赋给模板变量的名称

textformat is a block function used to format text. It basically cleans up spaces and special characters, and formats paragraphs by wrapping at a boundary and indenting lines.

textformat 用于格式化文本. 该函数主要清理空格和特殊字符,对段落按单词边界换行和行缩进等段落格式化处理.

You can set the parameters explicitly, or use a preset style. Currently "email" is the only available style.

用户可以明确设置各参数,或使用预处理风格. 目前只有唯一可用风格"email".

 

Example 8-18. textformat
Smarty手册范例 8-18. 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.
这是一份简单的Smarty手册和Smarty教材,熟练掌握Smarty模板,让您做项目事半功倍