https://github.com/willf/stencil
Stencil renders templated text with variables
https://github.com/willf/stencil
Last synced: 9 months ago
JSON representation
Stencil renders templated text with variables
- Host: GitHub
- URL: https://github.com/willf/stencil
- Owner: willf
- License: mit
- Created: 2023-06-23T04:34:52.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-26T18:48:30.000Z (almost 3 years ago)
- Last Synced: 2025-09-13T12:12:43.156Z (9 months ago)
- Language: Go
- Size: 4.23 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# stencil
Stencil renders templated text with variables. It supports:
- [Go templates](https://golang.org/pkg/text/template/)
- [Mustache templates](https://mustache.github.io/)
- Colon templates: `:name` -> `Bob` renders the string "Hi, :name!" as "Hi, Bob!"
```
❯ ./stencil --help
Usage: stencil [OPTIONS]
Stencil command: Convert templated text using variables
Options:
-f --file path to a template file (default: stdin)
-g --go use Go template syntax
-m --mustache use Mustache template syntax (default)
-c --colon use colon template syntax
-h --help print this help message
Other flags are passed as key=value pairs for use in the template
Stencil tries to be forgiving about whether keys get dashes or values have a =
❯ stencil -f examples/template.mustache name=Bob age=35
Name: |Bob|
Age: |35|
> stencil -f examples/template.mustache name="Bob Smith" age=35 --mustache
Name: |Bob Smith|
Age: |35|
❯ stencil -f examples/template.mustache name=Bob age=35 --mustache
Name: |Bob|
Age: |35|
❯ stencil -f examples/template.gotemplate name=Bob age=35 -g
Name: |Bob|
Age: |35|
❯ ./stencil -f examples/template.colon name=Bob age=35 --colon
Name: |Bob|
Age: |35|
```
## Install
```
gh repo clone willf/stencil
cd stencil
go install ./cmd/stencil
```