Templating and syntactic sugar
Tom Robinson
tom at alkali.spamfree.org
Mon Aug 6 10:37:22 EDT 2001
Hi,
To teach myself more python, I've set about writing a text templating
system. I know others exist, but none of them is exactly what I want.
:)
Currently I have the following sort of stuff in the template file to
be replaced by the system:
<? tpl.var="xyzzy" ?>
And the code to set this up looks like this:
tpl = Template('template.html')
tpl.var('xyzzy', 'Hello, world!')
print tpl.output()
You can get and set variables in the template with tpl.var(), but I
want to be able to do something like tpl.var.xyzzy = "Hello, world!",
just because I like that syntax, but still have this actually make a
method call. I'm pretty sure this is possible in python (with
operator overloading?), can anyone tell me how?
--
tom at alkali.spamfree.org
remove 'spamfree.' to respond
More information about the Python-list
mailing list