Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Brautkleider auf Topwedding.de

Find free files to download on allwhatyouwant.net

Looking For Affordable Wedding Dresses 2015 at Best Prices On TDBridal.com

Shop high quality cheap prom dresses on Dresswe.co.uk

Buy New Arrival Cheap Prom Dresses 2015 at JDBRIDAL Prom Dress Store

Advertisement

前置过滤器

前置过滤器是在模板编译之前调用的PHP函数。 该过滤器经常用于删除一些模板中的无用注释、检查注释的来源等等。

前置过滤器可以通过注册过滤器来调用, 或者放置到插件目录中,用 loadFilter()函数或者 设置 $autoload_filters来调用。

Smarty把模板源代码作为第一个参数传递到函数中,并期待函数返回经过处理的源代码。

Example 17.11. 使用前置过滤器

这个例子将删除全部模板中的HTML注释。


<?php
// 在PHP程序中
function remove_dw_comments($tpl_source, Smarty_Internal_Template $template)
{
    return preg_replace("/<!--#.*-->/U",'',$tpl_source);
}

// 注册过滤器
$smarty->registerFilter('pre','remove_dw_comments');
$smarty->display('index.tpl');
?>

  

参见 registerFilter(), 后置过滤器loadFilter().

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 12 plus 17? (Are you human?)

Advertisement