template_helpers.templatetags¶
The set` template tag add one or more context variables to the current template context. The context stack is respected.
{% set foo="bar" baz=1 %} {{ foo }} {{ baz }}
The
split
template filter splits a given string by spaces. If you want to split by something else, provide the devider as a argument to the filter.{{ "foo bar"|split }} {{ "foo-bar"|split"-" }}
The
starspan
template filter adds extra span element to star indicated text (“*text*”).{{ some_text_variable|starspan }}
The
merge_list
filter combines two lists.{% for element in first_list|merge_list:second_list %} {{ element }} {% endfor %}
To make the result list persistent use in combination with set tag.
{% set new_list=first_list|merge_lists:second_list %}
Bases:
django.template.loader_tags.IncludeNode
Render the specified template and context. Cache the template object in render_context to avoid reparsing and loading when used in a for loop.
Include template with object attributes injected to context. It takes object and template path as arguments. Object should have template_exposed_attributes list defined.
{% include_with obj 'path/to/included/template.html' %}
It is also possible to overvrite / add additional kwaegs.
{% include_with obj 'path/to/included/template.html' foo='bar'%}