A markup template compiler with data support.
Note: The weav package on PyPI is unrelated to this project.
- Render Jinja2 templates with data from YAML, JSON, or TOML files
- Support for multiple data files with deep merge
- Key-value parameters via command line
- Environment variable support (programmatic API)
- Flexible template search paths
- Read data from stdin
uv tool install git+https://github.com/dynamist/weav.gitgit clone https://github.com/dynamist/weav.git
cd weav
uv syncBasic usage with key-value parameters:
weav template.j2 --keyval name=WorldUsing a YAML data file:
weav template.j2 --data config.yamlUsing a JSON data file:
weav template.j2 --data config.jsonUsing a TOML data file:
weav template.j2 --data config.tomlMixing YAML, JSON, and TOML data files:
weav template.j2 --data base.yaml --data override.json --data final.tomlMultiple data files with key wrapping:
weav report.j2 --data items=tasks.yaml --data config.yamlReading data from stdin:
cat data.yaml | weav template.j2 --data -Using environment variables:
# Load all MYAPP_* environment variables
export MYAPP_NAME=World
export MYAPP_DEBUG=true
weav template.j2 --env MYAPP_
# Variables are available as lowercase keys: {{ name }}, {{ debug }}
# Combine with data files (env vars override file values)
weav template.j2 --data config.yaml --env MYAPP_Templates are searched in the following order:
- Package bundled templates
./templatesin current directory~/.local/share/weav/templates(user data directory)~/Documents/weav/templates(user documents)
You can also specify a direct file path to a template.
| Option | Description |
|---|---|
-d, --data |
YAML/JSON/TOML data file(s). Use KEY=FILE to wrap under key. Use - for stdin. |
-e, --env |
Environment variable prefix (e.g., MYAPP_). Can specify multiple times. |
-k, --keyval |
Key-value pairs (KEY=VAL). Can specify multiple times. |
-v, --verbose |
Show verbose output (loaded files, etc.) |
-V, --version |
Show version and exit |
weav provides a pluggable data source architecture for programmatic use:
from pathlib import Path
from weav.datasources import (
YamlDataSource,
JsonDataSource,
TomlDataSource,
EnvDataSource,
KeyvalDataSource,
ContextBuilder,
)
from weav.template import compile_template
# Build context from multiple sources
builder = ContextBuilder()
builder.add(YamlDataSource(Path("base.yaml")))
builder.add(JsonDataSource(Path("override.json")))
builder.add(TomlDataSource(Path("settings.toml")))
builder.add(EnvDataSource(prefix="MYAPP_")) # Read MYAPP_* env vars
builder.add(KeyvalDataSource(["debug=true"]))
context = builder.build()
# Or use the high-level API
result = compile_template(
"template.j2",
data_files=["config.yaml", "data.json", "settings.toml"],
keyvals=["name=World"],
)| Class | Description |
|---|---|
YamlDataSource |
Load data from YAML files |
JsonDataSource |
Load data from JSON files |
TomlDataSource |
Load data from TOML files |
EnvDataSource |
Load data from environment variables |
KeyvalDataSource |
Load data from key=value strings |
StdinDataSource |
Load data from standard input |
Apache License 2.0 - Copyright 2026 Dynamist AB