Search code examples
templatessyntaxyamlformattingjinja2

Using YAML formatter with .yaml jinja2 templates


I use jinja2 and a template .yaml file to expand into multiple actual .yaml files. The problem is that my formatter, the red hat yaml vscode extension, is rightfully mad about the jinja blocks and variable replacement syntax jinja uses inside my template file.

Does anyone have a solution, from ignoring certain lines or using different replace characters, that would let me use jinja templating syntax without the yaml formatter getting angy in the template?

Ive thought about ignoring lines with the replace/block characters, but that doesnt seem to be supported in settings of the extension. I also am not sure what characters I could use that would keep the yaml syntax happy.

Any ideas?


Solution

  • Okay, as an answer to my own question, I just put the jinja specific lines into comments in the yaml and the templating still renders fine and the formatter is happy. Id say thats good enough for my needs.