docker-gen icon indicating copy to clipboard operation
docker-gen copied to clipboard

Nested templates and include function

Open aywan opened this issue 3 years ago • 0 comments

Hi!

I have the task of including file content in the destination. Now I have a draft template in which I first "render" using bash, and then I use result as a template in docker-gen.

First, I added an import function that returns the contents of a file. Secondly, I added the ability to parse several templates. To do this, instead of one file, specify several through ;.

I tried to write the documentation, but I think that it must be corrected.

I don’t know how useful this feature will be, but at my case it can be very useful.

just example

header.inc:

# this file is auto generated

author.tmpl:

# created by {{ author.name }}
# email {{ author.email }}

result.tmpl:

{{ include "header.inc" }}
{{ template "author.tmpl" }}
---
some result content

executing: docker-gen "result.tmpl;author.tmpl" result:

# this file is auto generated
# created by 
# email 
---
some result content

aywan avatar Jan 21 '22 22:01 aywan