Trees | Indices | Help |
|
---|
|
source: http://djangosnippets.org/snippets/1350/
A smarter {% if %} tag for django templates.
While retaining current Django functionality, it also handles equality, greater than and less than operators. Some common case examples:
{% if articles|length >= 5 %}...{% endif %} {% if "ifnotequal tag" != "beautiful" %}...{% endif %}
|
|||
BaseCalc | |||
Or | |||
And | |||
Equals | |||
Greater | |||
GreaterOrEqual | |||
In | |||
IfParser | |||
TemplateIfParser | |||
SmartIfNode | |||
TestVar A basic self-resolvable object similar to a Django template variable. |
|
|||
|
|
|||
register = template.Library()
|
|||
logger = logging.getLogger('conditional_tags')
|
|||
OPERATORS = {'=':(Equals, True), '==':(Equals, True), '!=':(Eq
|
|||
BOOL_OPERATORS = 'or', 'and'
|
Imports: traceback, logging, template
|
|
|
OPERATORS
|
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Jan 24 19:48:45 2012 | http://epydoc.sourceforge.net |