Reputation: 471
Is there a way to pass the result of a template tag to another template tag?
I have 2 custom template tag as following:
@register.simple_tag
def foo():
return foo_value
@register.simple_tag
def bar(value):
return bar_value + value
and I want to to use them in my template like this:
{% load my_custom_tags %}
{% bar foo %}
I also use {% with %}
block but failed.
Upvotes: 3
Views: 685
Reputation: 477824
Yes, you can use an as
expression part in a template tag to store the result in a variable. For example:
{% load my_custom_tags %}
{% foo as foo_result %}
{% bar foo_result %}
Upvotes: 3