README
¶
miniplate
miniplate is a lightweight, size-optimized drop-in replacement for gomplate, designed for use in minimal Docker images where binary size matters. It implements the most commonly used template functions while deliberately omitting cloud provider integrations, remote datasource fetching, and other heavy dependencies that inflate the compiled binary.
YAML and TOML support are opt-in via build tags, keeping the default binary as small as possible. Templates written for gomplate are compatible with miniplate as long as they only use supported functions.
Requirements
- Go: Version 1.25 or higher.
- UPX (optional): Used by the default
maketarget to further compress the binary.
Installation
go install -trimpath -ldflags="-s -w" github.com/spacecafe/miniplate/cmd/miniplate@latest
To include TOML and/or YAML support (adds to binary size):
go install -tags=toml,yaml -trimpath -ldflags="-s -w" github.com/spacecafe/miniplate/cmd/miniplate@latest
Or build from source with maximum compression via UPX:
make
Usage
miniplate accepts the same flags as gomplate:
| Flag | Aliases | Description |
|---|---|---|
--in <file> |
-i, --file, -f |
Input template file (- for stdin, default) |
--out <file> |
-o |
Output file (- for stdout, default) |
--input-dir <dir> |
Process all files in a directory recursively | |
--output-dir <dir> |
Write output to this directory (requires --input-dir) |
|
--exclude <pattern> |
Exclude files matching a glob pattern (repeatable) | |
--context <name=URL> |
Add a data source as .<name> in templates (repeatable) |
Examples:
# Render a template from stdin
echo '{{ env.Getenv "HOME" }}' | miniplate
# Render a file with a JSON context
miniplate --in config.tmpl --out config.yaml --context cfg=data.json
# Process a directory of templates
miniplate --input-dir templates/ --output-dir output/ --exclude '*.skip'
# Read a secret from a file via _FILE suffix
SECRET_FILE=/run/secrets/token miniplate --in app.tmpl
Compatibility
The table below compares miniplate against gomplate v4. Function name links point to the gomplate documentation. ⚠️ indicates opt-in support via build tags.