Now this is going to be a little weird use-case. Maybe someone has some ideas.
Background
I’m writing a website that is very AJAX intensive. In fact there are hardly any full page reloads. This implies that a lot of template composition is done on the client side. For the moment I use some self written scripts in jQuery. To keep things reasonably simple I only use variable placeholders, like this: {{ somevar.someattr.someotherattr }}. I could probably use something like mustache to achieve a similar behaviour.
On the other hand, from time to time I like to be able to do some composition on the server side. I’m looking for a way to avoid pointless code duplication on the client & server side.
Idea
I’d like to be able to render Django templates in such a way, that certain gaps in the output would remain untouched. More specifically if a given variable is not supplied in the template rendering context, then the placeholder should still read {{ contents }}. I wonder whether this or a similar behaviour is possible to achieve using filters and/or tags.
I could just write {{ somevar.someattr|default:"{{ somevar.someattr }}" }}, however this isn’t very DRY.
You can set
TEMPLATE_STRING_IF_INVALIDto{{%s}}http://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATE_STRING_IF_INVALID