Dotiac::DTL::Tag::with - The {% with VARIABLE as NEWVARIABLENAME %} tag
Template file:
{% with object.expensivemethod as newvar %} {{ newvar|upper }} <b>{{ newvar|slugify }}{{ newvar|pluralize:"es" }}</b> {% endwith %}
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.
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.
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.