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 22 months ago by jonathanslenders
- Needs documentation unset
- Needs tests unset
- Owner changed from nobody to jonathanslenders
- Patch needs improvement unset
- Status changed from new to assigned
comment:3 Changed 22 months ago by jonathanslenders
comment:4 Changed 22 months ago by jonathanslenders
- Summary changed from Templatetag Library should keep track of which template tags are instances of simple_tag, assignment_tag and inclusion_tag. to Simple_tag, assignment_tag and inclusion_tag should remember their grammar in the compiled function. Also introduce something like block_tag.
comment:5 Changed 21 months ago by jonathanslenders
- Summary changed from Simple_tag, assignment_tag and inclusion_tag should remember their grammar in the compiled function. Also introduce something like block_tag. to Have a template tag grammar instead of handling token/parser for every tag, and make it possible to introspect the grammar.