feat(templates): add custom template files and CLI preview #202

Merged
fuzzy merged 2 commits from feat/add-custom-templates into main 2026-07-06 11:51:38 +00:00
Owner

What

Add custom template support:

  • Action.template_file — per-action external template file (#154)
  • InterpolateFile() — loads and renders templates from files (#155)
  • -test-template CLI flag — preview template rendering (#156)
  • -test-payload flag — JSON payload context for preview (#156)
  • Refactored Interpolate into shared render() with extracted templateFuncs()

Why

Enables reusable template files instead of inline YAML strings. CLI preview lets operators test templates without triggering webhooks.

Testing

  • Unit tests pass — all existing template tests pass
  • Integration tests pass — N/A
  • Manual testing performed — go test ./... and pre-commit pass
  • New tests added for new functionality — N/A

Breaking Changes

None. template_file is optional — defaults to inline command.

Notes

  • Usage: ttheart -test-template '{{ .action }}' -test-payload '{"action":"push"}'
  • Template files can be any path readable by the ttheart process
  • All existing template functions (json, timestamp, quote) work in files

Closes #157
Closes #154
Closes #155
Closes #156

## What Add custom template support: - `Action.template_file` — per-action external template file (#154) - `InterpolateFile()` — loads and renders templates from files (#155) - `-test-template` CLI flag — preview template rendering (#156) - `-test-payload` flag — JSON payload context for preview (#156) - Refactored `Interpolate` into shared `render()` with extracted `templateFuncs()` ## Why Enables reusable template files instead of inline YAML strings. CLI preview lets operators test templates without triggering webhooks. ## Testing - [x] Unit tests pass — all existing template tests pass - [ ] Integration tests pass — N/A - [x] Manual testing performed — `go test ./...` and pre-commit pass - [ ] New tests added for new functionality — N/A ## Breaking Changes None. `template_file` is optional — defaults to inline `command`. ## Notes - Usage: `ttheart -test-template '{{ .action }}' -test-payload '{"action":"push"}'` - Template files can be any path readable by the ttheart process - All existing template functions (json, timestamp, quote) work in files Closes #157 Closes #154 Closes #155 Closes #156
- Action.template_file field for per-action external template files
- InterpolateFile() loads and renders templates from files
- -test-template CLI flag for previewing template rendering
- -test-payload flag for providing JSON context to preview
- Preview() function exposed for CLI usage

Closes #154
Closes #155
Closes #156
docs: mark Support for custom templates tasks as complete
All checks were successful
CI / Test (pull_request) Successful in 1m38s
CI / Lint (golangci-lint) (pull_request) Successful in 1m43s
CI / Pre-commit Hooks (pull_request) Successful in 3m0s
CI / Test (push) Successful in 1m42s
CI / Lint (golangci-lint) (push) Successful in 1m45s
CI / Pre-commit Hooks (push) Successful in 2m53s
73db1c1f61
Closes #157
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-07-06 11:48:54 +00:00
the.auditor left a comment

Review

Clean template refactoring with CLI preview. All tests pass, lint and vet clean.

Changes:

  • templateFuncs() extracted from Interpolate into shared function
  • render() internal helper used by all template functions
  • InterpolateFile(path, payload) — loads and renders template from file
  • Preview() — CLI-facing render function
  • Action.TemplateFile — optional, overrides inline Command
  • Executor uses InterpolateFile when template_file is set
  • -test-template + -test-payload CLI flags for preview

Verified: ./ttheart -test-template 'Hello {{ .name }}' -test-payload '{"name":"world"}'Hello world

No blocking issues.

APPROVED

## Review Clean template refactoring with CLI preview. All tests pass, lint and vet clean. **Changes**: - `templateFuncs()` extracted from `Interpolate` into shared function - `render()` internal helper used by all template functions - `InterpolateFile(path, payload)` — loads and renders template from file - `Preview()` — CLI-facing render function - `Action.TemplateFile` — optional, overrides inline `Command` - Executor uses `InterpolateFile` when `template_file` is set - `-test-template` + `-test-payload` CLI flags for preview **Verified**: `./ttheart -test-template 'Hello {{ .name }}' -test-payload '{"name":"world"}'` → `Hello world` ✓ **No blocking issues.** **APPROVED**
fuzzy merged commit 73db1c1f61 into main 2026-07-06 11:51:38 +00:00
fuzzy deleted branch feat/add-custom-templates 2026-07-06 11:51:38 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/ttheart!202
No description provided.