Latest Version: 0.9.6.2

Buffet

Buffet style plug-in template rendering

Buffet implements template language plug-in support modeled highly on the Buffet Project from which this class inherits its name.


Methods

f __init__(self, default_engine=None, template_root=None, default_options=None, **config) ...

Initialize the Buffet renderer, and optionally set a default engine/options

f prepare(self, engine_name, template_root=None, alias=None, **config) ...

Prepare a template engine for use

This method must be run before the render method is called so that the template_root and options can be set. Template engines can also be aliased if you wish to use multiplate configurations of the same template engines, or prefer a shorter name when rendering a template with the engine of your choice.

f render(self, engine_name=None, template_name=None, include_pylons_variables=True, namespace=None, cache_key=None, cache_expire=None, cache_type=None, **options) ...

Render a template using a template engine plug-in

To use templates it is expected that you will attach data to be used in the template to the c variable which is available in the controller and the template.

When porting code from other projects it is sometimes easier to use an exisitng dictionary which can be specified with namespace.

engine_name
The name of the template engine to use, which must be 'prepared' first.
template_name
Name of the template to render
include_pylons_variables
If a custom namespace is specified this determines whether Pylons variables are included in the namespace or not. Defaults to True.
namespace
A custom dictionary of names and values to be substituted in the template.

Caching options (uses Beaker caching middleware)

cache_key
Key to cache this copy of the template under.
cache_type
Valid options are dbm, file, memory, or ext:memcached.
cache_expire
Time in seconds to cache this template with this cache_key for. Or use 'never' to designate that the cache should never expire.

The minimum key required to trigger caching is cache_expire='never' which will cache the template forever seconds with no key.

All other keyword options are passed directly to the template engine used.

See the source for more information.

Top