Skip to content

Support for jinja syntax in yaml variables #100

Open
@chekolyn

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 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 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.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions