Have a template tag grammar instead of handling token/parser for every tag, and make it possible to introspect the grammar.
|Reported by:||jonathanslenders||Owned by:||jonathanslenders|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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:1 Changed 4 years ago by
|Owner:||changed from nobody to jonathanslenders|
|Status:||new → assigned|
comment:4 Changed 4 years ago by
|Summary:||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 Changed 4 years ago by
|Summary:||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.|