﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
3791	Enhance functionality of {% if ... %} tag in a Django way.	nowell strite	Adrian Holovaty	"I understand the desire to provide templatetags to allow designers or non-programmers an easy interface for writing conditional statements in a template, and for not exposing too much logic at the template level. However, if only to combine those pesky tags, and to allow a more robust conditional evaluation system, I modified the existing !IfNode/do_if functions to allow for more useful conditional evaluations.

This patch allows conditional expressions that check for:

 * Equallity -- i == 1, i != 1
 * Greater/Less than -- i >= 1, i > 1, i < 1, i <= 1
 * Nested conditionals -- i >= 0 and i <= 10
 * Mixed and/or -- i == 15 or (i >= 0 and i <= 10)
 * List contains -- i in ('Apple', 'Orange', 'Pear'), 'Pear' in i
 * Negation -- i not in ('Apple', 'Orange', 'Pear'), not i

This keeps with the concept that we should only allow access to variables/dicts/objects/arrays in a Django template way, it resolves the value of variables (and only accepts Django Template syntax) in the same way all tags do, so this does not open up random python code execution.


{{{
{% if food in (""Steak"", ""Pizza"", ""Salad"", food_of_the_day) and (restaurant.meal == 'Lunch' or restaurant.customers >= 50) %}
    Might as well open up and feed them lunch!
{% else %}
    We're closed!
{% endif %}
}}}


"		closed	Template system	dev		wontfix			Design decision needed	1	0	0	0	0	0
