Replies: 1 comment
-
|
Apologies for the delayed response... You can indeed define variables: Another approach is to use a context instead of a datasource, which removes the need to use the $ gomplate --context person=person.json -i 'Hello {{ .person.name }}'
... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
so, if I use a json file for input, the examples at https://docs.gomplate.ca/datasources/ show that I can use this format
However, if I have a template where the "name" is referred to in a dozen places, typing out
{{ $person.name }}
rather than
{{ (datasource "person").name }}
is quite appealing ;)
Is it possible to define a var at the top of the template that stores the (datasource "person") and which can then be used throughout the template ?
Sorry, don't know go templating at all, frantically trying to teach myself it ...
Beta Was this translation helpful? Give feedback.
All reactions