Skip to content
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

Is it possible to use this library to load jinja2 yaml templates? #692

Open
syllogismos opened this issue Dec 13, 2022 · 0 comments
Open

Comments

@syllogismos
Copy link

I have a jinja2 yaml template and I want to be able to parse it using js-yaml.

Something like plugin system for ruamel.yaml from this answerl https://stackoverflow.com/a/44515747

On python you can do something like below after installing the jinja2 plugin for ruamel.yaml

import os
from ruamel.yaml import YAML


yaml = YAML(typ='jinja2')

with open('input.yaml') as fp:
    data = yaml.load(fp)

myArray = data['A']['B'][1]['myArray']
pos = myArray.index('val2')
myArray.insert(pos+1, 'val 3')

with open('output.yaml', 'w') as fp:
    yaml.dump(data, fp)

os.system('diff -u input.yaml output.yaml')

Is there any way to do this on javascript? I should be able to load a jinja2 yaml file, modify the yaml parts and dump it and still have the jinja2 templating variables/for loops and etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant