views:

207

answers:

1

I would like to learn how I can use nested template tags where the child template tag takes an argument like below:

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

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

+2  A: 

I would replace the child_tag with a custom filter. Something like:

{% parent_tag argument1|filtername:argument2 rest_of_parent_arguments %}

assuming "arguments" consists of at most 2 arguments. See here for custom filters:

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

Gabriel Ross
thanks for your answer. It's the exact solution for my question.
Tolga