Support for jinja syntax in yaml variables
- Dominant language
- Python
- Stars
- 135
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
## This is a feature request
It would be really nice to be able to use a jinja template to define variables programmatically.
I think [jinjyaml](https://github.com/tanbro/jinjyaml) may integrate really well with himl.
### Example of jinja defined variables.
```
---
env: prod
deep:
key3: v3
deep_list:
- item3
jinja_array: !j2 |
{% for i in range(10) %}
- sub{{i}}: {{loop.index}}
{% endfor %}
jinja_deep_list: !j2 |
{% for i in deep_list %}
- sub-jinja-{{i}}
{% endfor %}
```
### Produces
```
deep:
key1: v1
key2: v2
key3: v3
deep_list:
- item1
- item2
- item3
env: prod
jinja_array:
- sub0: 1
- sub1: 2
- sub2: 3
- sub3: 4
- sub4: 5
- sub5: 6
- sub6: 7
- sub7: 8
- sub8: 9
- sub9: 10
jinja_deep_list:
- sub-jinja-item1
- sub-jinja-item2
- sub-jinja-item3
```
I currently have a very alpha poc here https://github.com/adobe/himl/compare/master...chekolyn:jinjyaml_poc to produce the above example. It does introduce a new package dependency but it would open a lot of possibilities with the use of jinja syntax.
Contributor guide
Research direction
Review the requested Jinja/YAML behavior and the linked jinjyaml proof of concept first. Determine how the proposed dependency and !j2 examples would fit into himl; done means the examples render as shown without breaking existing YAML configuration behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100