3 define('PHPTAL_PRE_FILTER', 1);
4 define('PHPTAL_POST_FILTER', 2);
7 * Interface for source filter.
9 * This interface may be used to implement input / output filters.
11 * If the template intermediate php code is up to date, pre filters won't be
14 * Output filters are only called on main template result.
18 * class MyFilter extends PHPTAL_Filter
20 * function filter(&$tpl, $data, $mode)
22 * // just to present $mode usage for input/output filters
23 * if ($mode == PHPTAL_POST_FILTER) {
24 * return PEAR::raiseError("MyFilter mustn't be used as a pre-filter');
27 * // remove html comments from template source
28 * return preg_replace('/(<\!--.*?-->)/sm', '', $data);
32 * $tpl = PHPTAL('mytemplate.html');
33 * $tpl->addInputFilter( new MyFilter() );
34 * echo $tpl->execute();
38 * @author Laurent Bedubourg <laurent.bedubourg@free.fr>
43 * Filter some template source string.
45 * @param PHPTAL_Template $tpl
46 * The template which invoked this filter.
52 * PHPTAL_PRE_FILTER | PHPTAL_POST_FILTER depending if this filter
53 * is registered as a pre-filter or as a post-filter.
56 function filter(&$tpl, $data, $mode)