Package: repoze.bfg.mako
``repoze.bfg`` bindings for `Mako <http://www.makotemplates.org/>`_===================================================================These are bindings for the `Mako templating system<http://www.makotemplates.org/>`_ for the `repoze.bfg<http://bfg.repoze.org/`_ web framework.High-Level API--------------The API follows the pattern of the "default" template API for``repoze.bfg``, which includes three functions: ``get_template``,``render_template``, and ``render_template_to_response``.  From withina repoze.bfg view function, you might do::from webob import Responsefrom repoze.bfg.renderers import get_renderertemplate = get_renderer('templates/foo.mak')return Response(template.render_unicode(foo=1))Or::from repoze.bfg.renderers import renders = render('templates/foo.mak', {foo:1})return Response(s)Or::from repoze.bfg.renderers import render_to_responsereturn render_to_response('templates/foo.mak', {foo:1})All of these examples are equivalent.  The first argument passed in toeach of them (representing the template location) should be a filepath relative to the lookup loader root.The value passed to ``render`` or ``render_to_response`` should be oneof the following:- A *dictionary* representing the values passed to the template.- A *tuple*, consisting of two values in the form ``(function_name,values)``.  If a tuple is returned, the ``def`` named after``function_name`` in the template is rendered instead of the entiretemplate using the ``values`` provided, which must be a dictionary).Positional arguments to the function defined within the template arefilled in by name using the same-named values within the ``values``dictionary.Configuring the Loookup Loader------------------------------In your bfg application's ``.ini`` file, use a ``mako.directories``setting::[app:main]use = egg:mypackagemako.directories = mypackage:templatesanotherpackage:templatesreload_templates = truedebug_authorization = falsedebug_notfound = false``mako.directories`` should be a sequence of absolute directory namesor resource specifications, one per line.Other values:``mako.input_encoding``Set the mako template input encoding.  The default is ``utf-8``.``reload_templates``If this is ``True``, Mako templates will be checked for changes atevery rendering boundary.  This slows down rendering but isconvenient for development.Ensuring the Mako Renderer Extension is Active----------------------------------------------``repoze.bfg.mako`` can also act as a "renderer" for a view when it isactive in the ``repoze.bfg`` application you're developing::@bfg_view(renderer='templates/foo.mak')def aview(request):return {'foo':1}There are two ways to make sure that the mako extension is active.Both are completely equivalent.#) Ensure that some ZCML file with an analogue of the followingcontents is executed::<include package="repoze.bfg.mako"/>#) Call the ``add_renderer`` method of a Configurator in yourapplication:from repoze.bfg.mako import renderer_factoryconfig.add_renderer(.'mak', renderer_factory)config.add_renderer(.'mako', renderer_factory)In either case, files with the ``.mak`` and ``.mako`` extensions arenow considered to be Mako templates.Note that when mako is used as a ``renderer`` in this fashion, the``repoze.bfg`` context that is usually available as ``context`` withinthe template global namespace is available as ``_context`` (the``context`` name without the underscore is reserved for internal Makousage).Installation------------Install using setuptools, e.g. (within a virtualenv)::$ easy_install -i http://dist.repoze.org/bfg/dev/simple repoze.bfg.makoCreating a Mako ``repoze.bfg`` Project--------------------------------------After you've got ``repoze.bfg.mako`` installed, you can invoke thefollowing command to create a Mako-based ``repoze.bfg`` project::$ paster create -t bin/paster create -t bfg_mako_starterReporting Bugs / Development Versions-------------------------------------Visit http://bugs.repoze.org to report bugs.  Visithttp://svn.repoze.org to download development or tagged versions.0.3 (2010-09-19)----------------- A ``repoze.bfg.mako`` renderer may now be called with a *tuple*,consisting of two values in the form ``(function_name, values)``.If a tuple is provided to a renderer, the ``def`` named after``function_name`` in the template is rendered instead of the entiretemplate using the ``values`` provided, which must be a dictionary).0.2 (2010-09-06)----------------- Removed ``repoze.bfg.mako`` functions named ``render_template``,``render_template_to_response``, ``get_template`` and``get_renderer``.  As of ``repoze.bfg`` 1.3a6, use of thesefunctions should be replaced with usage of similarly-named functionspresent in the ``repoze.bfg.renderers`` module .- Added integration tests for imperative rendering and ZCML loading.0.1 (2010-07-24)----------------- Initial release.