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.
You can nest multiple templates to define increasingly specific layouts.
Nested folders are a way to manage your codes on a more granular level, where you can quickly put subfolders within a main folder. Create subfolders within folders, move folders into existing folders to form subfolders, and create or move codes anywhere in a nested folder structure.
The {% if %} tag evaluates a variable, and if that variable is “true” (i.e. exists, is not empty, and is not a false boolean value) the contents of the block are output. One can use various boolean operators with Django If Template tag.
A variable is a symbol within a template that outputs a value. Variable tags are surrounded by {{ and }} : My first name is {{ first_name }}. My last name is {{ last_name }}.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With