-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(jinja): add macros.jinja file to accumulate common macros #134
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just the doubled Jinja whitespace control, due to the linked comment.
Thanks for this, @noelmcloughlin. I think the idea itself is sound but we all need discuss how to proceed, with respect to consistency and a number of ongoing discussions:
If we're going to follow our current implementation scheme, then this should be something like: {%- from tplroot ~ "/libkwarg.jinja" import format_kwargs with context %} However, I am not proposing that we continue with this scheme. |
Hi @myii
macros are an advanced feature of a rendering language. It is probably a sound principle to hide the implementation since they are secondary libraries designed to cleanup overuse of jinja in SLS files.
Fixed. Let's stick with
There is no right answer. It's unclear if loading a single macro from a common library file incurs increased performance, compared to a modular library implementation. Buts It's a more simple implementation. We could start here and evolve. |
Here is another macro from prometheus-formula (only) which maybe portable too.
|
I'll close this as duplicate or #122 |
Best reviewed: commit by commit
Optimal code review plan
|
This PR introduces a 1st revision of a common
jinja/macros.j2
file to gather generic macros. The first revision includes aformat_kwargs
macro.Background:
The
format_kwargs
macro is generic solution used in two formulas-format_kwargs macro
This macro makes short work of rendering SLS lists which must be generated by mapping files and the switching of
grains
.Use Case
osfamilymap.yaml
package/install.sls