Reputation: 11888
I would like to have a templatetags where I could deal with my object's fields. So in my template I have something like :
{% myTag item %}
And in my templatetags :
@register.tag
def myTag (parser,token):
tag_name, item = token.split_contents()
...
However, token.split_contents() return me a string. How can I do to have my object instead of a string ?
Thanks.
Upvotes: 0
Views: 50
Reputation: 599610
Don't use the tag
decorator, which needs a separate Node class in order to resolve variables. Instead, use the simple_tag
decorator, which is passed the parameters directly.
@register.simple_tag
def myTag(item):
...
Upvotes: 1