hairyhenderson/gomplate

Processing mixed outputs between custom path & output-dir

RafPe opened this issue · 1 comments

Looking for some inisghts on controlling outputs of templating mix between templated files and dynamic outputs from templates.

For ease of example lets assume I have the following example.t file

Hello  {{ . }} 

I then have the following structure of folders/files for my template to be rendered from. Lets say I run it from /base/template/input

.
├── dynamic.tmpl
├── content_foo.txt
└── content_bar.tf

in the dynamic.tmpl I have the following setup

{{- range $hello_name := .mycontext.some_range_of_inputs }}
{{- $outPath := printf "hello.%s.txt" $hello_name }}
{{- tmpl.Exec "hello" $hello_name | file.Write $outPath }}
{{- end }}

Now the problem I am trying to solve is to be able to template the outputs from /base/template/input into lets say /results/output. Rigjt now however I struggle with the fact of how to pass the --output-dir context into the dynamic templates and how not to include that file in the final results of the templating :) ? So the expected result is

.
├── hello_bar.txt
├── hello_xyz.txt
├── hello_abc.txt
├── content_foo.txt
└── content_bar.tf

Sorry for the delay in answering... Have a look at https://docs.gomplate.ca/usage/#--exclude-and---include - I think that does what you want.

Closing for now as there's no obvious action to be taken - feel free to re-open, or start a discussion if you need more help.