[Templates] Something comparable to Template Toolkit in Python?
Darren Chamberlain
dlc@sevenroot.org
Thu, 11 May 2006 09:11:00 -0400
--VrqPEDrXMn8OVzN4
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
* Sean McAfee <eefacm at gmail.com> [2006/05/09 15:26]:
> Anyway, I need a templating system for various things, and I have
> yet to find one for Python that comes anywhere near the power of the
> Template Toolkit. [...] Does anyone know of a system with power
> comparable to TT for Python?
I was in the same position a few years ago, and started porting TT to
Python. While Python is nice for some things, I found that it was
simply too difficult to create textual code generators for the
language -- the significant-whitespace thing means that you can't
simply generate code; you need to maintain and pass around too much
information about things like indendation. It quickly turned into a
bookkeeping exercise, and got old fast.
You might want to look at Jemplate[0], which is a "port" of TT to
Javascript. Basically, it's a small runtime engine that executes
precompiled templates, generated by a Template::Directive replacement
that generates JavaScript instead of Perl. You could do something
similar for Python, modeled on the Jemplate model, although you'd
still need to deal with the whitespace thing. You'd also have to deal
with the fact that there is a separate compilation step, although you
might be able to either spin this as a feature ("It detects errors
before you upload your templates!"), or possibly hook Pymplate (that's
your Python TT thingie :) into your publishing process, so that new
templates are automatically compiled as they are put into production.
In any case, I'd be interested in hearing about what you come up with,
as would (I imagine) others on the list.
(darren)
[0] http://blog.ingy.net/2006/02/jemplate_a_template_toolkit_fo.html
--=20
<Alanna> Saying that Java is nice because it works on all OS's is like
saying that anal sex is nice because it works on all genders
-- <http://bash.org/?338364>
--VrqPEDrXMn8OVzN4
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFEYzfkzsinjrVhZaoRAtppAJkBpxOqRIc2IGeDdr9P56RnTla3twCeM946
UewzrxkCmPBLEM/843zvthM=
=cFxM
-----END PGP SIGNATURE-----
--VrqPEDrXMn8OVzN4--