dongpoliu / django-template-utils

Automatically exported from code.google.com/p/django-template-utils
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Added a "if_in" and "if_not_in" tag to "comparison.py" #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I've added the {% if_in %}-tag to the comparison.py templatetag module.

With the submitted patch it's possible to check whether a context variable 
is a member of a list or not.

Usage:

{% if_in list_item in list %}
<p>{{ list_item }} is a member of {{ list }}.</p>
{% else %}
<p>{{ list_item }} is not a member of {{ list }}.</p>
{% endif_in %}

{% if_not_in list_item in list %}
<p>{{ list_item }} is not a member of {{ list }}.</p>
{% else %}
<p>{{ list_item }} is a member of {{ list }}.</p>
{% endif_not_in %}

Original issue reported on code.google.com by phxx...@gmail.com on 12 Jul 2007 at 12:29

Attachments:

GoogleCodeExporter commented 9 years ago
As this hasn't been merged into the project, I've generated a new patch which 
works for 
svn r109.

Original comment by mrjohnni...@gmail.com on 17 Dec 2009 at 9:15

Attachments:

GoogleCodeExporter commented 9 years ago
Nice stuff. Thanks.

Original comment by info.ksa...@gmail.com on 29 Jul 2010 at 8:01