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

doc: illustrate how to do templating #472

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,22 @@ Feature: to interact with objects in the context
| test1/bob.yaml |
| /test2/test/../bob.yaml |


Scenario: we can use file as templates
Given that userTemplatePath is:
"""
templates/userTemplate.yaml
"""
When name is "Alice"
When alice is:
"""
{{{[&userTemplatePath]}}}
"""
Then alice is equal to:
"""yml
id: 1
name: Alice
"""

Scenario: we cannot write a file outside the resource folder of the build
* it is not true that we output in "../../bob.yaml":
"""yml
Expand Down Expand Up @@ -424,9 +439,25 @@ Feature: to interact with objects in the context
And object.first == "?e .*bird.*"
And object.second == "?doesNotContain bird"

Scenario: we can use a variable as a template
Given that template is:
"""yml
property: "{{value}}"
"""
And that value is "test"
Then template is:
"""yml
property: "test"
"""
But if value is "test2"
Then template is:
"""yml
property: "test2"
"""

Scenario: we can define a variable while templating it
Given that object is a Map:
"""yml
"""yml
property: "{{{[id: randomUUID.get]}}}"
time: "{{{[created_at: @now]}}}"
"""
Expand Down
2 changes: 2 additions & 0 deletions tzatziki-core/src/test/resources/templates/userTemplate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id: 1
name: {{name}}