kajiki
kajiki copied to clipboard
missing the transformation filters
hello friends,
and many thanks for providing kajiki.
with genshi, i was using transformation filters, that allowed me to give a last touch to some tags' attributes.
how could i hook a callback in kajiki template _render_attrs? how could _render_attrs know the tag name it was called for? should such callback be hooked somewhere else?
thanks in advance, alex
well i did monkey patch the template loaded in the (subclassed loader)._load by changing _render_attrs. to find the tag name of the rendering attrs, i monkey patched iter to save the current chunk in self, but this should be a stack, i think.
Note that even though we can implement a stack to track the tags, it won't be possible to actually implement transformations. As Kajiki is designed like Jinja it has no representation of the DOM that can be modified at runtime. To achieve dynamic tags those should be created from python code itself
thanks @amol . but the template is being parsed and compiled to a dom, thus a hook may be plugged to influence the process, either during the parsing, or on the parsed doc. xmltemplate may receive an user made parser, that would inherit the _Parser, which is standard sax parser.