我是靠谱客的博主 谨慎煎饼,这篇文章主要介绍Smarty中的注释和截断功能介绍,现在分享给大家,希望可以做个参考。

注释

复制代码 代码如下:
复制代码

{* 这是一个单行Smarty注释 来自于uoften.com,网页源代码里看不见*}


{* 这是一个多行
   Smarty注释
   并不发送到浏览器
*}

模板注释由星号包围,继而由分隔符包围,型如:{* 这是一个注释 *}。Smarty注释不会在最终模板的输出中显示,这点和不同。前者对于在模板中插入内部注释有用,因为没有人能看到。;-)

http://www.itlearner.com/code/smarty_cn/language.basic.syntax.html

截断truncate

复制代码 代码如下:
复制代码

$smarty->assign('hxtitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');

模板为:

复制代码 代码如下:
复制代码

{$hxtitle}
{$hxtitle|truncate}
{$hxtitle|truncate:30}
{$hxtitle|truncate:30:""}
{$hxtitle|truncate:30:"---"}
{$hxtitle|truncate:30:"":true}
{$hxtitle|truncate:30:"...":true}
{$hxtitle|truncate:30:'..':true:true}

输出为:
复制代码 代码如下:
复制代码

Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after...
Two Sisters Reunite after
Two Sisters Reunite after---
Two Sisters Reunite after Eigh
Two Sisters Reunite after E...
Two Sisters Re..ckout Counter.

可以不用在PHP里截取了:http://www.itlearner.com/code/smarty_cn/language.modifier.truncate.html

最后

以上就是谨慎煎饼最近收集整理的关于Smarty中的注释和截断功能介绍的全部内容,更多相关Smarty中内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(139)

评论列表共有 0 条评论

立即
投稿
返回
顶部