nbreport.templating.load_template_environment(context_path=None, extra_context=None, system_context=None)

Load the context (cookiecutter.json) and Jinja template environment.

context_path : pathlib.Path or str, optional

Path to the cookiecutter.json context file, if available. If a path isn’t provided, no template context is gathered from a cookiecutter.json file.

extra_context : dict, optional

A dictionary of key-value terms (equivalent to the cookiecutter.json file’s structure) that override values obtained from any cookiecutter.json file (at context_path).

If context_path is None, then the context is populated entirely from extra_context.

system_context : dict, optional

A dictionary of key-value terms that are available to templates, but outside the cookiecutter context. This argument is used by nbreport.instance.ReportInstance.render to pass system metadata from the nbreport.yaml file into the Jinja context.

context : dict

The context is a dictionary with a key called 'cookiecutter' that is a dict with template key-value pairs obtained from the combination of the context_path and extra_context.

This context dictionary can be used directly by Jinja to render a template.

jinja_env : cookiecutter.environment.StrictEnvironment

The Jinja template environment that is pre-loaded with the context.


Internally this function uses cookiecutter.generate.generate_context to combine a cookiecutter.json file with extra_context.