2 years ago
#41974

emjay_010
How to parse below yaml/xml in jinja template?
Example format for Yaml file below is a yaml file, which takes xml also as an input.. but should be parsed in jinja code as a template.
service1:
name:
path: 'pathtofile=/home/example.xml'
CustomDefinition: |
<?xml version="1.0" encoding="UTF-8" ?>
//some xml content
service2:
name:
path: 'pathtofile=/home/example2.xml'
CustomDefinition: |
<?xml version="1.0" encoding="UTF-8" ?>
//some xml content
I've tried below jinja code:
{%- for key, value in service1.items() recursive%}
{%- if key != "name" %}
{{loop(value.items())}}
{%- else %}
{{value}}
{%- endif %}
{% endfor %}
python
parsing
yaml
jinja2
pyyaml
0 Answers
Your Answer