Задать вопрос

Тел: +7 965 3737 888

468

Просмотров

1

Ответов

{% with %} template tag

Add a value to the context (inside of this block) for easy access.

Provides a way to stay DRYer in your templates.

NOTE: This tag is now in Django core, so if you have Django >0.96 (or SVN) then you do NOT need this.

Вопрос полезен? Да0/Нет0
file_4322.py(1.5Кб)
None

Ответы (1):

Ответxin:06.05.2007
Ответ полезен? Да0/Нет0

This tag is more useful, but if I need set more variables this tag use two lines for variables.

For this, I use the tag "set" (-- {% set base_url "../" %} --) (-- {% set obj object %} --). So, when I need change much variable name for an include tag, this save me the half of lines:

{% with category.categories.all as category_list %}
    {% set dir_url "../" %}
    {% set show_user True %}
    {% include "category_list.html" %}
{% endwith %}}