Created
January 11, 2011 16:17
-
-
Save d6veteran/774644 to your computer and use it in GitHub Desktop.
Custom filter for Webapp templates: match item to items in List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.appengine.ext.webapp import template | |
from django import template as django_template | |
def in_list(value, arg): | |
""" | |
Given an item and a list, check if the item is in the list. | |
Usage: | |
{% if item|in_list:list %} | |
in list | |
{% else %} | |
not in list | |
{% endif %} | |
""" | |
return value in arg | |
register = template.create_template_register() | |
ifinlist = register.filter(in_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment