cement.ext.ext_handlebars

Cement handlebars extension module.

class cement.ext.ext_handlebars.HandlebarsOutputHandler(*args, **kw)[source]

Bases: cement.core.output.OutputHandler

This class implements the IOutput interface. It provides text output from template and uses the Handlebars Templating Language for Python via the pybars library. Please see the developer documentation on Output Handling.

Note This extension has an external dependency on pybars3. You must include pybars3 in your applications dependencies as Cement explicitly does not include external dependencies for optional extensions.

class Meta[source]

Bases: object

Handler meta-data.

label = 'handlebars'

The string identifier of the handler.

overridable = False

Whether or not to include handlebars as an available to choice to override the output_handler via command line options.

_setup(app)[source]

Called during application initialization and must setup the handler object making it ready for the framework or the application to make further calls to it.

Parameters:app (instance) – The application object.
render(data, template)[source]

Take a data dictionary and render it using the given template file.

Parameters:data (dict) – The data dictionary to render.
Keyword Arguments:
 template (str) – The path to the template, after the template_module or template_dirs prefix as defined in the application.
Returns:The rendered template text
Return type:str
class cement.ext.ext_handlebars.HandlebarsTemplateHandler(*args, **kw)[source]

Bases: cement.core.template.TemplateHandler

This class implements the Template Handler interface. It renders content as template, and supports copying entire source template directories using the Handlebars Templating Language for Python via the pybars library. Please see the developer documentation on Template Handling.

Note This extension has an external dependency on pybars3. You must include pybars3 in your applications dependencies as Cement explicitly does not include external dependencies for optional extensions.

class Meta[source]

Bases: object

Handler meta-data.

helpers = {}

Custom helpers

label = 'handlebars'

Handler label

partials = []

List of partials to preload

_setup(app)[source]

Called during application initialization and must setup the handler object making it ready for the framework or the application to make further calls to it.

Parameters:app (instance) – The application object.
render(content, data)[source]

Render the given content as template with the data dictionary.

Parameters:
  • content (str) – The template content to render.
  • data (dict) – The data dictionary to render.
Returns:

The rendered template text

Return type:

str