NAME

Dotiac::DTL::Tag::if - The {% if [not ]VARIABLE1[ or [not ]VARIABLE2[ or ..]]|[and [not ]VARIABLE2[ and ..]] %} tag

SYNOPSIS

Template file:

{% if var %}
	var is true
{% endif %}
{% if var %}
	var is true
{% else %}
	var is not true
{% endif %}
{% if not var %}
	var is not true
{% endif %}
{% if not var %}
	var is not true
{% else %}
	var is true
{% endif %}
{% if var and var2 and not var3 %}
	....
{% endif %}
{% if var or not var2 or var3 %}
	....
{% endif %}

DESCRIPTION

Conditional rendering of templates, everything between {% if .. %} and {% else %} or {% endif %} is only rendered if the condition in the if clause is true.

The part between {% else %} and {% endif %}, if exists, is only rendered if the condition is false.

The condition

You can link conditions with either "and" or "or", but not both (there is a problem with precedence), you have to use two {% if %}'s for that.

{% if var1 %}
	{% if var2 or var3 %}
		This would be the same as "if var1 and (var2 or var3)", if that would work.
	{% endif %}
{% endif %}

You can negate a variable in any case with a "not" before it:

{% if not var %}
	....
{% endif %}

{% if not var1 and var2 and not var3 %}
	...
{% endif %}
{% if not var1 or var2 or not var3 %}
	...
{% endif %}

False values

False is:

0 # The number 0
0.00 # The number 0.0
"" # An empty string
"0" # A string containing a null
undef # A null value
{} # An empty hash
[] # An empty list/array
An unknown variable, even if $Dotiac::DTL::TEMPLATE_STRING_IF_INVALID is set to something true.
not "a true value" # not negates true to false and false to true.

True values

Everything else is true, including references to objects which are false and references to empty strings.

SEE ALSO

http://www.djangoproject.com, Dotiac::DTL

BUGS AND DIFFERENCES TO DJANGO

If you find any, please report them

LEGAL

Dotiac::DTL was built according to http://docs.djangoproject.com/en/dev/ref/templates/builtins/.

AUTHOR

Marc-Sebastian Lucksch

perl@marc-s.de