I'm thinking about extending filters in next version of PHPTAL.

What do you need?

Base class vs Interface

Is abstract base class ok? (myfilter extends PHPTAL_filter), or do you need an interface? (myfilter extends myclass implements PHPTAL_Filter) or both?

Base class makes it easier to extend filters in the future (I can add methods without having everyone change their filters), but won't let you use your own base class (do you ever use one?)

Source code vs W3C DOM vs PHPTAL DOM prefilters

I could expose DOM to filters, which would let you write more accurate prefilters, but PHPTAL's DOM doesn't have any nice helper methods like getElementBy…(), and may change from version to version.

Would you rather use W3C DOM? (php.net/dom). W3C DOM will convert entities to real characters (e.g.   will become invisible) and probably will change other minor details too.

What interface would be best to specify which type of filter you want? A callback method? Separate interfaces? Multiple methods in the class?


Do you need to have filters applied in order different from order they were added to PHPTAL? E.g.


Do you need to remove filters that were already added?

Do you need special filtering of templates called via macros?

Filtering from within templates

It might be useful to configure filtering from within a template, e.g. to remove all whitespace from part of the page.

Any ideas for interface and syntax? How to define multiple filters? How to specify which are prefilters (filter source code once) and postfilters (filter output every time)?


Currently template code is recompiled whenever you change _class_ of the filter, but PHPTAL doesn't check what the filter actually does. Do you need better control over caching of compiled templates? (e.g. recompile when parameters of any filter change)

regards, Kornel

PHPTAL mailing list

Reply via email to