2010-10-26 26 views
0

Smarty的具有{條}功能:Zend在Smarty中有{strip}這樣的東西嗎?

{strip} 
<table border='0'> 
<tr> 
    <td> 
    Hello world 
    </td> 
</tr> 
</table> 
{/strip} 

,其輸出:

<table border='0'><tr><td>Hello world</td></tr></table> 

我也希望這樣做在Zend中(以減少叮咬的量發送對每個請求),而無需安裝Smarty的。

但是,我不想將代碼添加到每個Layout/.phtml文件,所以前端控制器插件會很好。

+0

我確實發現http://framework.zend.com/wiki/display/ZFPROP/Zend_Filter_Minify_Html+-+Nick+Daugherty但是這還沒有實現,所以問題仍然 – 2010-10-26 23:14:53

回答

5

爲什麼不使用Smarty使用的相同正則表達式。這是很簡單:

function strip($str, $replace = ' ') 
{ 
    return preg_replace('#\s+#', $replace, $str); 
} 
+0

但做查看它的助手,使其乾燥:) – 2010-10-30 16:30:20

相關問題