Django comes with great tools for creating custom template tags.
Register simple_tag and assign_tag and analyze the contents of incoming tokens and convert them to args, kwargscorrectly resolved to their links (let's say the variable was passed).
Is there an easy way to add this behavior to a regular tag?
I need to use an object parser, so I need to use a regular tag, but it seems to me that I am wading through a lot of code to play the parser args, kwargs.
@register.tag(name='snippet')
def snippet_with_defaults(parser, token):
bits = token.split_contents()[1:]
bits
I need a tag that works as follows:
{% snippet foo=bar bar=baz %}
This is a glorious django template tag!
{% endsnippet %}
It seems like this is such a common problem (parser args, kwargs for tag arguments) that it should have a django snippet or something like that!