templates
Templates module.
- class homer.templates.Renderer(base_path: str, base_private_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.base_private_path (
str
, default:''
) -- a secondary base path to initialize the Jinja2 environment with. Templates that are not found in base_path will be looked up in this secondary private location.
- 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 (
typing.Mapping
) -- the dictionary of variables to pass to Jinja2 for replacement.
- Raises:
homer.exceptions.HomerError -- on error.
- Return type:
- Returns:
The rendered template.