True. Its a rather naive system. What it does offer however is that you
can give it to the creative types and say "Just throw it together in
dreamweaver and put little {rarara} tags in the coders can take care of
the rest. What I've done in th past is to build a little render object
that has an abstract function thats overridden that (A) knows to load the
correct template (B) Knows how to fill in the details and (C) calls the
apply_template() function in the class. Then these can be nested or
whatever. You can then add goodness like cacheing etc to the rendering
core of the class.


--
Shayne O'Neill..   trådkrämare
http://perth.indymedia.org
"I trust God speaks through me. Without that, I couldnt do my job."
--George W Bush.
http://atheism.about.com/b/a/099745.htm


On Sun, 2 Jan 2005, Frank Barknecht wrote:

> Hallo,
> Shayne ONeill hat gesagt: // Shayne ONeill wrote:
>
> >
> > Template engine in 6 lines :)
> >
> > f =open('/templatedir/' + name, 'r')
> > template = f.read()
> > f.close()
> > for k,v replacelist():
> >       template = template.replace(str(k),str(v))
> > print template
> >
> > You start with a template file which is plain ol' html with lines like
> > <div class="raraa">{name}</div>
>
> If you use "templates" like:
>
>  <div class="raraa">%(name)s</div>
>
> you can even omit the "for k,v ..." loop altogether and just write:
>
> tpl = f.read()
> replacelist["name"] = "doobeedoo"
> tpl = tpl % replacelist
>
> And Python 2.4 has an even nicer syntax for this.
>
> However "plain ol' html" is not what I would consider a real template
> language, as that would include control structures like for-loops etc.
>
> One might argue, that Python code can be a template language then
> itself, though. PSP and Kid work this way behind the curtain anyway.
>
> Ciao
> --
>  Frank Barknecht                               _ ______footils.org__
>
>
>
> -------------------------------------------------------
> The SF.Net email is sponsored by: Beat the post-holiday blues
> Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
> It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
> _______________________________________________
> Webware-discuss mailing list
> Webware-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/webware-discuss
>


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Webware-discuss mailing list
Webware-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to