multipackage.utilities.template module

jinja based template rendering.

Summary

Functions:

render_template Render a template using the variables in info.

Reference

multipackage.utilities.template.render_template(template_name, info, out_path=None, adjust_newlines=True, filters=None)[source]

Render a template using the variables in info.

You can optionally render to a file by passing out_path. This assumes that you are rendering text files that will be saved with UTF-8 encoding.

By default, it modifies the generated template to have platform-specific newlines. If you want the template’s output to be unmodified, pass adjust_newlines=False.

Parameters:
  • template_name (str) – The name of the template to load. This must be a file in config/templates inside this package
  • out_path (str) – An optional path of where to save the output file, otherwise it is just returned as a string.
  • info (dict) – A dictionary of variables passed into the template to perform substitutions.
  • adjust_newlines (bool) – Automatically convert the output to have platform specific newlines. Default: True.
  • filters (dict) – Optional dict of callables that are provided as filters to the underlying template.
Returns:

The rendered template data.

Return type:

string