djangosnippets.org: Latest snippets tagged with 'switch'https://djangosnippets.org/tags/switch/2008-08-13T05:25:24.696946-05:00Switch template tag
2008-08-13T05:25:24.696946-05:00adurdinhttps://djangosnippets.org/snippets/967/<p>The <code>{% switch %}</code> tag compares a variable against one or more values in
<code>{% case %}</code> tags, and outputs the contents of the matching block. An
optional <code>{% else %}</code> tag sets off the default output if no matches
could be found:</p>
<pre><code>{% switch result_count %}
{% case 0 …</code></pre>
Freely redistributableSwitch/case conditional tags
2008-07-12T17:54:20.353658-05:00gabrielteratoshttps://djangosnippets.org/snippets/878/<p>This tag allow you to use C-like switch tag in your templates.
It is useful for sequencial and repetitive <code>{% ifequal %}</code> tags.</p>
<p>To install it in your project, you just need to follow <a href="http://www.djangoproject.com/documentation/templates_python/#extending-the-template-system">these instructions</a></p>
Freely redistributableSwitch/case tags.
2007-07-03T15:41:40.790521-05:00jacobianhttps://djangosnippets.org/snippets/300/<p>Meant mostly as a demo of how to do complex block tags, here's a switch/case implementation.</p>
<p>It's deliberately simplistic: no default cases, no multiple values for the same case, etc. This is so that you can focus on the technique.</p>
<p>Pay particular attention to how both switch and case pull …</p>
Freely redistributable