Use subtemplate #1014
-
Hello, I want to add a subtemplate file to emulate boilr or pythonic equivalent (cookiecutter) thus i create a template like this ____________________________________ mainfile.tpl {{ define "color_definition" -}} {{ if (datasource "sessions").USECOLORLIB -}} #same but with inclusion of external {{ tmpl.Exec "color_definition" (datasource "sessions") }} ____________________________________ color_definition.tpl {{ .USECOLORLIB }} ______________________________________ param.json
As far as i could guess the problem is in the file.Read part, any though about doing this another way ? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @Tindome, thanks for logging this. I've converted it to a discussion since it fits better here. I don't think you need to use $ gomplate -t color_definition=./tpl/color_definition.tpl -d sessions=./params.json -f makefile.tpl -o makefile Does that help? |
Beta Was this translation helpful? Give feedback.
Hi @Tindome, thanks for logging this. I've converted it to a discussion since it fits better here.
I don't think you need to use
file.Read
ortmpl.Exec
here at all - it looks like the external nested templates feature (i.e.--template
/-t
) should work for you:$ gomplate -t color_definition=./tpl/color_definition.tpl -d sessions=./params.json -f makefile.tpl -o makefile
Does that help?