Reputation: 13880
Ok, i write this:
@register.simple_tag
def get_something(data, var1, var2):
if data:
if var1:
if var2:
return { 'variable': True }
return return { 'variable': False }
but this:
{% get_something 1 0 1 %}
{% if not variable %}
...
{% endif %}
is still not working... Always show "..."
Upvotes: 2
Views: 803
Reputation: 16644
Try to return the value directly and use something like this:
{% get_something 1 0 1 as variable %}
{% if not variable %}
...
{% endif %}
I think it's not the goal of a template tag to update the global template context as it's very hard to see that the context gets updated as a user of your template tag.
Upvotes: 4