开发者

How to extend jinja2 builtin tags?

I am trying to override the default implementation of the raw/endraw block tag in jinja2. I am familiar with how to write custom tag extensions, but in this case my extension is not firing (the default implementati开发者_如何学JAVAon of the raw tag is still being called). Can this even be done? If not, can someone point me to where in the source the raw tag is implemented so I can patch it to fit my needs.

Thanks.


It looks like overriding the raw/endraw tags is not supported.

The code for dealing with the raw/endraw tags is directly in the lexer, and the handling is hard coded.

So you would probably have to patch the code. Luckily, the code is hosted on github, so it would be easy to have your own shallow fork of jinja2, but still keep up to date with future improvements from the main distribution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜