views:

49

answers:

1

What do I need to implement to add a new templating language to repoze.bfg? Will the framework send my plugin absolute paths or package relative paths, or both depending?

+2  A: 

The package at http://svn.repoze.org/repoze.bfg.jinja2/trunk/repoze/bfg/jinja2/ provides add-on Jinja2 bindings for BFG. Basically, you do create a package like that, then allow folks to wire it into their systems.

There are two levels of integration. The first is just an import-level integration that would allow people to do something like:

from my.template.system import render_template_to_response

def aview(request): return render_template_to_response('some/relative/path.myt')

Aping the render_template* methods in repoze.bfg.jina2, replacing them with analogues for your favored template system would give you this.

The other level of integration is to allow your templating system to be used as a "renderer". This permits, for example:

@bfg_view(renderer="some/relative/path.myt") def aview(request): return {'a':1}

To do this, ape the "renderer_factory" function in repoze.bfg.jinja2, and then get folks to add this renderer in their configuration via "config.add_renderer(renderer_factory, '.myt')" (imperatively) or by including the ZCML file you ship along with your package in their ZCML.

Chris McDonough