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

Тел: +7 965 3737 888

507

Просмотров

0

Ответов

Switch template tag

<p>The {% switch %} tag compares a variable against one or more values in
{% case %} tags, and outputs the contents of the matching block.  An
optional {% else %} tag sets off the default output if no matches
could be found:</p>
{% switch result_count %}
    {% case 0 %}
        There are no search results.
    {% case 1 %}
        There is one search result.
    {% else %}
        Jackpot! Your search found {{ result_count }} results.
{% endswitch %}

<p>Each {% case %} tag can take multiple values to compare the variable
against:</p>
{% switch username %}
    {% case "Jim" "Bob" "Joe" %}
        Me old mate {{ username }}! How ya doin?
    {% else %}
        Hello {{ username }}
{% endswitch %}

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