Dotiac::DTL::Tag::ifequal - The {% ifequal VARIABLE1 VARIABLE2 %} tag
{% ifequal post.date comment.date %} At the same time {% else %} {{ comment.date|timesice:post.date }} ago {% endifequal %}
Compoares two variables, and if they are equal, the content is rendered.
If they are not equal and an optional {% else %} block is found, that block is rendered.
If given an array or hash, it will only compare the length (like perl does), since there is no default array or hash comparision (This will change with perl6)
So you can write:
{% ifequal loop 3 %} Loop has three elements {% endifequal %}
But to stay compatible with Django, you should write:
{% ifequal loop|length 3 %} Loop has three elements {% endifequal %}
If you want to compare the content, use this:
{% ifequal loop|stringformat:"s" otherloop|stringformat:"s" %} ... {% endifqual %}
Warning: This might be quite slow, that's why it isn't default.
http://www.djangoproject.com, Dotiac::DTL
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.