Excellent points Tobi. I like the {{content_for_layout}} suggestion,
although I have a couple concerns I will address later in this
message.
When I talk about Django, I want to stress that I have no practical
experience with the framework myself, just the word of some Python-
influenced friends and the Django docs.
That said, in Django you can tell a template to inherit from another
template that contains its layout and has placeholders for the child
template's content. It looks something like this:
base.html:
<html>
<head>
<title>{% block title %}{% endblock %}</title>
</head>
<body>
<img src="sitelogo.gif" alt="Logo" />
{% block content %}{% endblock %}
</body>
</html>
article_detail.html:
{% extends "base.html" %}
{% block title %}Articles for {{ year }}{% endblock %}
{% block content %}
<h1>Articles for {{ year }}</h1>
{% for article in article_list %}
<p>{{ article.headline }}</p>
<p>By {{ article.reporter.full_name }}</p>
<p>Published {{ article.pub_date|date:"F j, Y" }}</p>
{% endfor %}
{% endblock %}
(taken from the Django docs:
http://docs.djangoproject.com/en/dev/intro/overview/#design-your-templates)
So your templates become nothing but a collection of blocks that get
pushed into their placeholders. I like this in that the views are
declaring their own layouts rather than some other layer doing it for
them; this is a great adherence to SRP and improves clarity.
Please correct me if I'm wrong; it looks like Liquid's include tag is
similar to Rails partials. I'd be more apt to compare Django's blocks
to Rails yield :placeholder/content_for :placeholder instead, except
that this uses no magic. Every block is defined with a name. The
controller, or other rendering class, isn't making view decisions like
which layout to use.
At the moment the {{content_for_layout}} system should work well for
my needs. However, having inheritable templates would go a long way
towards improving code clarity. And there's no reason both patterns
can't persist. Since {{content_for_layout}} merely makes use of local
variables and isn't a feature in and of itself.
Just out of curiosity, did Liquid arise out of Django or was there
some common ancestor of the two?
Thanks!
Joe