Skip to content

Parsing Helm template syntax #556

Answered by eemeli
reiv asked this question in Q&A
Jun 25, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Is it feasible to extend the parser to be able to deal with {{ ... }} outside of strings as a discrete node (similarly to how the library already lets you define custom scalars)?

No, because that's valid YAML that has a non-scalar meaning, and it's parsed as an object with an object key already by the lexer.

However, you could add a wrapper around the yaml parser to make it work:

  1. Replace all of the {{ ... }} sequences with some string that's a valid YAML plain scalar, like __TEMPLATE_VAR_#__ where # is an identifier that you keep track of.
  2. Parse the result with parseDocument().
  3. Use a visitor to find and replace the __TEMPLATE_VAR_#__ strings with their original values.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@reiv
Comment options

Answer selected by reiv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants