Dotiac::DTL::Tag::if - The {% if [not ]VARIABLE1[ or [not ]VARIABLE2[ or ..]]|[and [not ]VARIABLE2[ and ..]] %} tag
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 %}
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.
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 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.
Everything else is true, including references to objects which are false and references to empty strings.
http://www.djangoproject.com, Dotiac::DTL
If you find any, please report them
Dotiac::DTL was built according to http://docs.djangoproject.com/en/dev/ref/templates/builtins/.
Marc-Sebastian Lucksch
perl@marc-s.de
To install Dotiac::DTL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dotiac::DTL
CPAN shell
perl -MCPAN -e shell install Dotiac::DTL
For more information on module installation, please visit the detailed CPAN module installation guide.