[Web-SIG] Standardized template API
Ben Bangert
ben at groovie.org
Fri Feb 3 22:45:37 CET 2006
On Feb 3, 2006, at 1:34 PM, Ben Bangert wrote:
> # setup the myghty engine
> from myghty.wsgi import engine
> myghtyengine = engine(template_root='/some/path/to/templates')
>
> # render a template
> def render_myghty(template):
> environ['wti-source'] = template
> environ['wti-vars'] = myvars
> environ['wsgi.application_root'] = environ['SCRIPT_NAME']
> environ['SCRIPT_NAME'] += environ['PATH_INFO']
> environ['PATH_INFO'] = ''
> return myghtyengine(environ, start_response)
Thought I'd ammend this. Since the engine would implement the
Template Spec, it'd do what it needs to inside, so a realistic
example would be:
# render a template
environ['wti-source'] = template
environ['wti-vars'] = myvars
return myghtyengine(environ, start_response)
And of course the implementation details of how it plays with environ
are left up to it. Someone who wanted something even easier could
just have a wrapper on that call in their framework, etc.
Cheers,
Ben
More information about the Web-SIG
mailing list