Have a template tag grammar instead of handling token/parser for every tag, and make it possible to introspect the grammar.
|Patch needs improvement:
Right now, if people use @register.simpletag (or assignment_tag/inclusion_tag), a compiled parser function will be registered in the library.tags mapping.
This however, is insufficient, if you need to do some introspection on the available template tags. I'd like to know for instance which template tags in module X are an instance of simpletag and would thus create a SimpleNode.
Right now, we are unable to accurately build a real AST from the template without manually defining which templatetags behave in which way. This is also required for AST transformations, like template compression and such.
I guess, it would be great to encourage people to always use @register.simpletag or anything that uses the built-in Node classes of Django. We can't force that, but it has a lot of advantages.
Change History (18)
comment:4 by , 11 years ago
|Templatetag Library should keep track of which template tags are instances of simple_tag, assignment_tag and inclusion_tag. → Simple_tag, assignment_tag and inclusion_tag should remember their grammar in the compiled function. Also introduce something like block_tag.
comment:5 by , 11 years ago
|Simple_tag, assignment_tag and inclusion_tag should remember their grammar in the compiled function. Also introduce something like block_tag. → Have a template tag grammar instead of handling token/parser for every tag, and make it possible to introspect the grammar.