How to use nested template tags with arguments?

I would like to know how I can use nested template tags, where the child template tag takes an argument, as shown below:

{% parent_tag {% child_tag arguments %} rest_of_parent_arguments %} 

In the above line, I would like to use the return value of the child tag as an argument to the parent tag.

+4
source share
1 answer

I would replace child_tag ​​with my own filter. Sort of:

 {% parent_tag argument1|filtername:argument2 rest_of_parent_arguments %} 

Assuming that the β€œarguments” consist of no more than two arguments. See here for custom filters:

http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#writing-custom-template-filters

+6
source

All Articles