mloq.templating
Contents
mloq.templating
#
This module defines common functionality for rendering and writing File templates.
Module Contents#
Functions#
|
Render a jinja template with the provided parameter dict. |
|
Create new file containing the rendered template found in source_path. |
Attributes#
- mloq.templating.jinja_env#
- mloq.templating.render_template(file, kwargs)[source]#
Render a jinja template with the provided parameter dict.
- Parameters
file (mloq.files.File) – File object representing the jinja template that will be rendered.
kwargs (Mapping[str, Any]) – Dictionary containing the parameters key and corresponding values that will be used to render the template.
- Returns
String containing the rendered template.
- Return type
str
- mloq.templating.write_template(file, config, path, ledger, overwrite=False)[source]#
Create new file containing the rendered template found in source_path.
- Parameters
file (mloq.files.File) – File object representing the jinja template that will be rendered.
config (omegaconf.DictConfig) – OmegaConf dictionary containing the parameters key and corresponding values that will be used to render the templates.
path (Union[pathlib.Path, str]) – Absolute path to the folder where the file will be written.
ledger (mloq.record.Ledger) – Book keeper to keep track of the generated files.
overwrite (bool) – If False, copy the file if it does not already exists in the target path. If True, overwrite the target file if it is already present.
- Returns
None.