Latest Version: 0.9.6.1

templating

Buffet templating plugin and render functions

The Buffet object is styled after the original Buffet module that implements template language neutral rendering for CherryPy. This version of Buffet also contains caching functionality that utilizes Beaker middleware to provide template language neutral caching functionality.

A customized version of BuffetMyghty is included that provides a template API hook as the pylonsmyghty engine. This version of BuffetMyghty disregards some of the TurboGears API spec so that traditional Myghty template names can be used with / and file extensions.

The render functions are intended as the primary user-visible rendering commands and hook into Buffet to make rendering content easy.


Functions

f render(*args, **kargs) ...

Render a template and return it as a string (possibly Unicode)

Optionally takes 3 keyword arguments to use caching supplied by Buffet.

Examples:

1
2
3
content = render('/my/template.mako')
print content
content = render('/my/template2.myt', fragment=True)

Note

Not all template languages support the concept of a fragment. In those template languages that do support the fragment option, this usually implies that the template will be rendered without extending or inheriting any site skin.

f render_response(*args, **kargs) ...

Pending Deprecation: render_response will be deprecated (trigger a DeprecationWarning) in Pylons 0.9.7, and support for it will be removed in a future version of Pylons. Please return the response content directly (via the render function) instead.

Returns the rendered response within a Response object

See render for information on rendering.

Example:

1
2
def view(self):
    return render_response('/my/template.mako')

Classes

C 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.

This class contains 3 members.

C MyghtyTemplatePlugin(...) ...

Myghty Template Plugin

This Myghty Template Plugin varies from the official BuffetMyghty in that it will properly populate all the default Myghty variables needed and render fragments.

This class contains 4 members.

See the source for more information.

Top