Hello, I've been using Template Toolkit for about four years now and have
recently been working more and more in the Python+Django framework on a new
project I've been constructing.
The templating language in Django has given me some inspiration for what
would, in my opinion, make the TT templates we use in our business much
cleaner and easier to maintain.
Django has the concept of "extend"ing another template. This is somewhat
similar at first glance to the "wrapper" directive in TT, however the Django
"extends" directive allows you to override specific contents of a base
template.
That is, for the general and simple example, you would define a base
template with the layout of your site and some default contents.
Django template code:
index.html:
<div id="head">
{% block head %}
<h1>CatConnoisseur.com</h1>
{% endblock %}
</div>
<div id="content">
{% block content %}
<p>Welcome to the front page of my site!</p>
{% endblock %}
</div>
If you were to load the index.html template through the Django template
processor, it would show you a page that had a headline,
"CatConnoisseur.com" and a paragraph text, "Welcome to the front page of my
site!"
Then you would make another template:
photos.html:
{% extends "index.html" %}
{% block content %}
<p>Here are some cats!</p>
<ul>
<li><img src="/img/cat1.jpg"/></li>
</ul>
{% endblock %}
The "extends" block means, roughly, to take index.html and replace any
blocks inside of it with the ones defined in the current file, photos.html.
So when you load this page through the Django template processor you'd see
the default "CatConnoisseur.com" header and then the contents of the main
content div would be replaced by the "Here are some cats!" text and the
photo.
Has any thought been put into putting something similar into Template
Toolkit? Is there strong opposition for any reason? I am considering making
a local branch and writing this functionality in for my own purposes. Is
anybody else interested?
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates