cement.ext.ext_mustache

Cement mustache extension module.

Note This extension has an external dependency on pystache. Cement explicitly does not include external dependencies for optional extensions.

  • In Cement >=3.0.8 you must include cement[mustache] in your applications dependencies.

  • In Cement <3.0.8 you must include pystache in your applications dependencies.

class cement.ext.ext_mustache.MustacheOutputHandler(*args: Any, **kw: Any)[source]

Bases: OutputHandler

This class implements the Output Handler interface. It provides text output from template and uses the Mustache Templating Language. Please see the developer documentation on Output Handling.

class Meta[source]

Bases: Meta

Handler meta-data.

label: str = 'mustache'

The string identifier of this handler.

overridable: bool = False

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

_setup(app: App) None[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: Dict[str, Any], template: str = None, **kw: Any) str[source]

Take a data dictionary and render it using the given template file. Additional keyword arguments passed to stache.render().

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_mustache.MustacheTemplateHandler(*args: Any, **kw: Any)[source]

Bases: TemplateHandler

This class implements the Template Handler interface. It renderd content as template, and supports copying entire source template directories using the Mustache Templating Language. Please see the developer documentation on Template Handling.

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

class Meta[source]

Bases: Meta

Handler meta-data.

label: str = 'mustache'

Unique identifier (str), used internally.

render(content: str | bytes, data: Dict[str, Any]) str[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