-
Notifications
You must be signed in to change notification settings - Fork 6
Labels
feature-requestNew feature requestNew feature request
Description
Abstract
Recent work on generated Clib and .NET APIs increased the use of Jinja2 templates. At the moment, the templates build on standard Jinja concepts, including loops and conditionals, but do not take advantage of Template Inheritance and Macros, among several others. The use of nested templates and macros has the potential to improve readability and facilitate long-term code maintenance.
Motivation
Describe the need for the proposed change:
- What problem is it trying to solve? ... improve readability of templates.
- Who is affected by the change? ... code maintainers.
- Why is this a good solution? ... facilitate long-term maintenance.
Possible Solutions
While the current templates are somewhat convoluted, the resolution approach is straightforward. From the Python side, all nested template components need to be made available as dictionaries, where rendering would involve the following sketch:
jinja_templates = {
# dictionary of templates
'parent.j2': <...>, # loaded from YAML as before
'child.j2': <...>, # loaded from YAML as before
}
env = Environment(loader=DictLoader(jinja_templates), **kwargs)
template = env.get_template('child.j2')
output = template.render(*args)References
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature-requestNew feature requestNew feature request