[Web-SIG] Standardized template API

Kevin Dangoor dangoor at gmail.com
Tue Jan 31 16:53:41 CET 2006

On 1/30/06, Ian Bicking <ianb at colorstudy.com> wrote:
> Peter Hunt wrote:
> > I think all it would take is a Web-Sig (and perhaps a PEP) blessing the
> > TurboGears template engine plugin API [1].

Thanks for bringing this up, Peter. Discussions to date have been ad
hoc on the TurboGears mailing list, and it's better to open this up.

> >
> > Thoughts?
> >
> > Peter Hunt
> >
> > [1] http://www.turbogears.org/docs/plugins/template.html
> I concur.  I've started using it in a project of mine.  There's a couple
> things I'd like to add that have come up on the TG list:
> * Add "template_file" and "template_string" arguments to .render(),
> which take filenames and strings.

Would template_file be expecting an absolute filename? (just
confirming that this wouldn't do any more lookups or path searching...
just open and go!)

These seem pleasant enough to me.

> * Add a find_template callback, which given a filename can, for
> instance, use a search path to find the file.  So the framework or
> application would pass this function into the plugin somehow.  Maybe
> this could be extended some for use in situations where templates aren't
> found on the filesystem.

Being able to pass a string to render() would also allow use where the
templates aren't in the filesystem.

In fact, if find_template is just returning a filename, then this
mechanism couldn't work for pulling the template from a database.

> * Add some methods for quoting -- one for text that is already a
> HTML/XML literal, and one for text that should be quoted.  Some
> templates default one way (quote everything unless explicitly asked not
> to in some way), and some the other way (include everything as though it
> is markup, unless explicitly quoting it).  This makes it possible --
> though not incredibly easy -- to write some template-language-neutral
> libraries.  I would assume most applications would actually be written
> to a specific templating language, so this is only for libraries that go
> out of their way to be neutral.

That sounds potentially hairy. Not the specifics of having the quoting
methods, but rather the notion of having template-language-neutral
libraries that use these. Are you thinking of something specific? that
might make it clearer to me.


More information about the Web-SIG mailing list