The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Dotiac::DTL::Tag::with - The {% with VARIABLE as NEWVARIABLENAME %} tag

SYNOPSIS

Template file:

        {% with object.expensivemethod as newvar %}
                {{ newvar|upper }}
                <b>{{ newvar|slugify }}{{ newvar|pluralize:"es" }}</b>
        {% endwith %}

DESCRIPTION

Renames a VARIABLE to a NEW VARIABLE NAME for the block from {% with ... %} to {% endwith %}. This is quite useful, since VARIABLEs can contain slow lookups and/or method calls which then can be stored as in an easy NEW VARIABLE NAME for fast access. This way a slow method call is only performed once.

BUGS AND DIFFERENCES TO DJANGO

I don't know if Django allows this as well, but this implementation also allows filters as in any other variable, this can be used to save results of filters.

        {% with var|lower|striptags|slugify as postid %}
                <a href="post.pl?id={{ postid }}" title="{{ postid }}">Go to {{ postid }}</a>
        {% endwith %}

If you find anything else, please let me know.

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