kajiki icon indicating copy to clipboard operation
kajiki copied to clipboard

missing the transformation filters

Open alexbodn opened this issue 7 years ago • 3 comments

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

alexbodn avatar Aug 29 '16 02:08 alexbodn

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.

alexbodn avatar Aug 29 '16 06:08 alexbodn

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

amol- avatar Aug 29 '16 08:08 amol-

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.

alexbodn avatar Aug 29 '16 18:08 alexbodn