hashicorp / hashicorp/consul-template

Feature request: parse sub-templates dynamically

Open
#1,402 10 comments 39 reactions 0 assignees View on GitHub
docs enhancement
Dominant language
Go
Stars
4.8k
Forks
801
Avg merge
4h 5m
Merged PRs (30d)
6

Description

Converting this issue into a feature request.

Context below but basically add a way to parse the contents of a file as a template. Right now the most obvious solution is with a new `parseTemplateFiles` template function that uses the text/template's `ParseFiles` method.

[edited by @eikenb to convert into feature request]

-- original
I try to use File directive to render multiple template to one file. But file doesn't render anything. Is that correct behaviour or am I miss something?

### Consul Template version

consul-template v0.24.1 (c54d0abc)

### Configuration

test.ctmpl:
```liquid
{{ file "/root/a.ctmpl" }}
{{ file "/root/b.ctmpl" }}
```
/root/a.ctmpl
```liquid
{{ key "foo" }}
```
/root/b.ctmpl
```liquid
{{ key "baz" }}
```

### Command

```shell
$ consul kv put foo bar
$ consul kv put baz qux
consul-template -template "test.ctmpl:/tmp/out.txt" -once
```

### Expected behavior
```shell
bar
qux
```

### Actual behavior
```shell
{{ key "foo" }}
{{ key "baz" }}
```

Contributor guide

Open the contributing guide

Research direction

Start by examining the existing `File` directive and the proposed `parseTemplateFiles` function, then read Go's `text/template.ParseFiles` behavior. Done means a template can parse file contents dynamically so the `foo` and `baz` lookups render as `bar` and `qux`, as described in the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.