Smarty中的注釋和截?cái)喙δ芙榻B
注釋
{* 這是一個(gè)單行Smarty注釋 來(lái)自于jb51.net,網(wǎng)頁(yè)源代碼里看不見(jiàn)*}
{* 這是一個(gè)多行
Smarty注釋
并不發(fā)送到瀏覽器
*}
模板注釋由星號(hào)包圍,繼而由分隔符包圍,型如:{* 這是一個(gè)注釋 *}。Smarty注釋不會(huì)在最終模板的輸出中顯示,這點(diǎn)和不同。前者對(duì)于在模板中插入內(nèi)部注釋有用,因?yàn)闆](méi)有人能看到。;-)
http://www.itlearner.com/code/smarty_cn/language.basic.syntax.html
截?cái)鄑runcate
$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
相關(guān)文章
使用TinyButStrong模板引擎來(lái)做WEB開(kāi)發(fā)
使用TinyButStrong模板引擎來(lái)做WEB開(kāi)發(fā)...2007-03-03
ThinkPHP關(guān)聯(lián)模型操作實(shí)例分析
ThinkPHP關(guān)聯(lián)模型操作實(shí)例分析,需要的朋友可以參考下2012-09-09

