I have two suggestions how to improve Django template system (see
http://code.djangoproject.com/ticket/8088 ):
1. Since we have add filter, that adds a value to integer variable,
why not implement cat filter, which will concatenate strings? I think,
it would be useful for many developers!
2. include tag has two options: template name could be specified
either as a quoted string, or as a variable. But for all that template
filters cannot be used. It would be nice to allow developers to
specify template name more flexibly, for example:
{% include var_name|lower %}
or even like this (page5_ka.txt):
{% include "page"|cat:pageid|cat:LANGUAGE_CODE|cat:"_.txt" %}
The diffs attached to the ticket do these things. At the same time,
new revision of template system will be fully backwards-compatible
with previous. An only exception is - using quoted strings with quotes
inside, like this:
{% include "a"mysterious"template.txt" %}
Currently, template system accepts this string as a template name with
doublequotes inside, while modified - won't. But, IMHO, nobody will
name templates this case.
WHAT I NEED IT FOR:
I have one template in my project to render some static pages,
which are also in templates directory, formatted with textile,
and included into my template with this tag:
{% block content %}
{% filter textile %}
{% include pagename|cat:"_"|cat:LANGUAGE_CODE|cat:".txt" %}
{% endfilter %}
{% endblock %}
Also, I have one URL entry in my urls.py:
(r'^(?P<pagename>rules|about|intel|history)/?$',
direct_to_template, {'template': 'page.html'}),
0 code lines in models!
Of course, Thanks to flexible architecture of Django,
this behaviour could be easily implemented as custom template tags and filters
(as I did for my project), but maybe it would be useful for other
developers as well.