djangosnippets.org: Latest snippets tagged with 'ifregex'https://djangosnippets.org/tags/ifregex/2009-05-26T12:04:43.074523-05:00Template tag "ifregex" and "ifnotregex"
2009-05-26T12:04:43.074523-05:00arthurfurlanhttps://djangosnippets.org/snippets/1531/<p>Outputs the contents of the block if the second argument matches (or not, depending on the tag) the regular expression represented by the first argument.</p>
<p>Usage:</p>
<pre><code>{% ifregex "^/comments/" request.path %}
...
{% endifregex %}
{% ifnotregex "^/comments/" request.path %}
...
{% else %}
...
{% endifnotregex %}
</code></pre>
Freely redistributable