Marc - Sebastian Lucksch > Dotiac-0.8 > Dotiac::DTL::Tag::ifnotequal

Download:
dotiac/Dotiac-0.8.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.8   Source   Latest Release: Dotiac-0.8_1

NAME ^

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

SYNOPSIS ^

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

DESCRIPTION ^

Compoares two variables, and if they are NOT 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:

        {% ifnotequal loop 3 %}
                Loop has not three elements
        {% endifnotequal %}

But to stay compatible with Django, you should write:

        {% ifnotequal loop|length 3 %}
                Loop has not three elements
        {% endifnotequal %}

If you want to compare the content, use this:

        {% ifnotequal 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: