Skip to content

feat(tx3c): render template output paths through Handlebars - #363

Merged
scarmuega merged 1 commit into
mainfrom
work/work-9c5ab72281778b74c419144c89cb67abd6474200
Sep 27, 2026
Merged

scarmuega merged 1 commit into
mainfrom
work/work-9c5ab72281778b74c419144c89cb67abd6474200

Conversation

@scarmuega

Copy link
Copy Markdown
Contributor

Summary

  • A template file's relative path may contain Handlebars expressions. tx3c codegen renders each path with the same helpers and data as the file's contents, for built-in templates and custom template directories alike, so a template can emit layouts such as Sources/{{pascalCase tii.protocol.name}}Client/ or src/main/java/land/tx3/generated/{{snakeCase tii.protocol.name}}/. Paths without expressions render unchanged.
  • Rendered paths that are empty, absolute, or have an empty, . or .. segment are errors naming the source template file. Two files rendering to the same output path are an error naming both.
  • The built-in and directory branches now share one load/resolve/write path (TemplateFile + write_output), instead of two static-file code paths.

Tests

  • New golden custom template tests/codegen/custom/templated-paths/ pins a protocol-named Swift and Java layout, plus a static file inside a templated directory, for every fixture.
  • Unit tests cover helper-rendered paths, unchanged plain paths, empty paths, absolute paths, .. and . segments, empty segments, collisions, and rendering errors.
  • All existing golden output is unchanged.
  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets --all-features --locked -- -D warnings, cargo test -p tx3c --locked pass.

Plan: plans/lang-codegen-templated-output-paths.md (tx3 domain). The renderer-contract note for sdk-spec is reported on the plan for the spec owner to apply.

🤖 Generated with Claude Code

A template file's relative path may contain Handlebars expressions. tx3c
renders each path with the same helpers and data as the file's contents,
for built-in templates and custom template directories alike, so a
template can emit layouts such as `Sources/{{pascalCase
tii.protocol.name}}Client/`. Paths without expressions render unchanged.

Rendered paths that are empty, absolute, or have an empty, `.` or `..`
segment are errors naming the source template file, as are two files
that render to the same path.

The golden corpus gains a `templated-paths` custom template that pins a
protocol-named Swift and Java layout for every fixture; existing golden
output is unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@scarmuega
scarmuega marked this pull request as ready for review September 27, 2026 12:27
@scarmuega

scarmuega commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Merge observed.

Plan: plans/lang-codegen-templated-output-paths.md
QA-approved head: 161407283a8929ef8fdde94b9b826e415827721a

Trellis will verify the human merge evidence, adopt the domain pin, and retire the plan. No further merge action is needed.

@scarmuega
scarmuega merged commit a6ea9ec into main Sep 27, 2026
14 checks passed
@scarmuega
scarmuega deleted the work/work-9c5ab72281778b74c419144c89cb67abd6474200 branch September 27, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant