charmhelpers.core.templating¶
-
charmhelpers.core.templating.
render
(source, target, context, owner='root', group='root', perms=292, templates_dir=None, encoding='UTF-8', template_loader=None, config_template=None)¶ Render a template.
The source path, if not absolute, is relative to the templates_dir.
The target path should be absolute. It can also be None, in which case no file will be written.
The context should be a dict containing the values to be replaced in the template.
config_template may be provided to render from a provided template instead of loading from a file.
The owner, group, and perms options will be passed to write_file.
If omitted, templates_dir defaults to the templates folder in the charm.
The rendered template will be written to the file as well as being returned as a string.
Note: Using this requires python-jinja2 or python3-jinja2; if it is not installed, calling this will attempt to use charmhelpers.fetch.apt_install to install it.