Skip to content

Instantly share code, notes, and snippets.

@pivotaljohn
Created May 21, 2021 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pivotaljohn/e7a77ab1af0765d97d838bf575927bd0 to your computer and use it in GitHub Desktop.
Save pivotaljohn/e7a77ab1af0765d97d838bf575927bd0 to your computer and use it in GitHub Desktop.
Example 1
#@ load("@ytt:template", "template")
#! First, capture the YAML document in a "Fragment Function"
#!
#@ def my_template(foo):
---
field1: #@ foo + "1"
field2: #@ foo + "2"
#@ end
#@ def another_template(prefix):
#@ return my_template(prefix + "-yada-")
#@ end
#! Again, in the same file, I start a YAML document (`---`), and replace it with the document produced by `another_template()`, passing in the value for `foo`:
--- #@ template.replace(another_template("a"))
--- #@ template.replace(another_template("b"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment