On 11-12-2009 at 13:31:31 Murat Corlu <muratco...@gmail.com> wrote:

We want to use a custom namespace and tags in our template files like 'fbml'. I mean, we want to render a month select box by writing a tag to our template like that:

<foo:select data="monthList" />

To use a custom namespace I added a xmlns attribute to outer tag. ( <div xmlns:foo="bar"> ) So, now, I want to render these namespace tags with custom template files. For example above, I want to generate select.html template file for all foo:select tags. I only know I can make this with filterDOM. I can walk on all elements of templates and if I find a tag of my custom namespace, I can run a custom php function and manipulate content of this tag.

But, I wonder, is there any better solution to make this? For example, can DTD files help me? Do you have any suggessions?

DTDs can't help much. Best they can do is to replace custom entity with code fragment (&fooselect;), but it's an optional (and problematic) feature in XML, and PHPTAL doesn't implement it.

I think replacement with filterDOM is a good idea. That's what this was meant for.

You don't need to transform much. You can just set tal:define and metal:use-macro attributes on this element, e.g.:

<foo:select tal:define="data monthList" metal:use-macro="foo.xhtml/select"/>

and it will be replaced with macro's code.

BTW: I've added setAttributeNS to SVN to make that possible. There might be more embarrassing omissions like that - let me know if you need any other DOM methods.

regards, Kornel

PHPTAL mailing list

Reply via email to