Marc - Sebastian Lucksch > Dotiac-0.8_1 > Dotiac::DTL::Tag::ifequal

Download:
dotiac/Dotiac-0.8_1.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.8   Source  

NAME ^

Dotiac::DTL::Tag::ifequal - The {% ifequal VARIABLE1 VARIABLE2 %} tag

SYNOPSIS ^

        {% ifequal post.date comment.date %}
                At the same time
        {% else %}
                {{ comment.date|timesice:post.date }} ago
        {% endifequal %}

DESCRIPTION ^

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.

BUGS AND DIFFERENCES TO DJANGO ^

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.

SEE ALSO ^

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

LEGAL ^

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

AUTHOR ^

Marc-Sebastian Lucksch

perl@marc-s.de

syntax highlighting: