templates

Templates module.

class homer.templates.Renderer(base_path: str)[source]

Bases: object

Load and render templates.

Initialize the instance.

Parameters

base_path (str) -- the base path to initialize the Jinja2 environment with. All templates path must be relative to this base path.

render(template_name: str, data: Mapping) → str[source]

Render a template with the given data.

Parameters
  • template_name (str) -- the name of the template to load without the file extension.

  • data (dict) -- the dictionary of variables to pass to Jinja2 for replacement.

Raises

HomerError -- on error.

Returns

the rendered template on success. None: on failure.

Return type

str