add template processing builtin#110
Merged
hinshun merged 1 commit intoopenllb:masterfrom Apr 19, 2020
Merged
Conversation
hinshun
reviewed
Apr 19, 2020
Contributor
hinshun
left a comment
There was a problem hiding this comment.
An alternative is to use with option like a map. For example:
string secretPath() {
template <<-EOM
{{- if .CI -}}
/path/to/ci/secret
{{- else -}}
/path/to/user/secret
{{- end -}}
EOM with option {
stringField "CI" string { localEnv "CI"; }
}
}
| # For template syntax documentation see: | ||
| # https://golang.org/pkg/text/template/ | ||
| # | ||
| # @param the text of the template |
Contributor
Author
I thought about it a while, I think this makes the most sense. It will be less cumbersome when we fix #100 and I think it provides flexibility going forward. I will update the PR for |
Contributor
Author
|
@hinshun updated PR with option::template |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
adding a basic templating function. can be used like:
The part I don't like about this is the argument data into the template. The PR currently passes the variadic arguments as a
[]stringslice when there is more than one argument to template, otherwise it will pass just a singlestringargument if only 1 variadic arg. I am not sure there is a more logical approach. If we wanted to pass named arguments to allow for{{ .name }}we would have to have some syntax that supports maps, which we dont have yet.