load_template_environment¶
-
nbreport.templating.
load_template_environment
(context_path=None, extra_context=None, system_context=None)¶ Load the context (
cookiecutter.json
) and Jinja template environment.Parameters: - context_path :
pathlib.Path
orstr
, optional Path to the
cookiecutter.json
context file, if available. If a path isn’t provided, no template context is gathered from acookiecutter.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 anycookiecutter.json
file (atcontext_path
).If
context_path
is None, then the context is populated entirely fromextra_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 bynbreport.instance.ReportInstance.render
to pass system metadata from thenbreport.yaml
file into the Jinja context.
Returns: - context :
dict
The context is a dictionary with a key called
'cookiecutter'
that is adict
with template key-value pairs obtained from the combination of thecontext_path
andextra_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.
Notes
Internally this function uses
cookiecutter.generate.generate_context
to combine acookiecutter.json
file withextra_context
.- context_path :