Skip to content

Replace Handlebars templating with direct string rendering - #1468

Merged
DZakh merged 3 commits into
mainfrom
claude/handlebars-dependency-r1zj45
Jul 22, 2026
Merged

Replace Handlebars templating with direct string rendering#1468
DZakh merged 3 commits into
mainfrom
claude/handlebars-dependency-r1zj45

Conversation

@DZakh

@DZakh DZakh commented Jul 22, 2026

Copy link
Copy Markdown
Member

Remove the Handlebars templating system and replace it with direct Rust string rendering for template generation. This simplifies the codebase by eliminating the need for .hbs template files and the handlebars dependency.

Changes

  • Removed Handlebars infrastructure:

    • Delete hbs_dir_generator.rs which recursively processed .hbs template files
    • Remove handlebars dependency from Cargo.toml
    • Delete all .hbs template files from templates/dynamic/
  • Implemented direct rendering methods:

    • Add env_template.rs module with render() function for .env file generation (used by both init and contract import)
    • Add render_package_json() method to InitTemplates struct with comprehensive test coverage for ReScript, TypeScript, and extra dependencies
    • Add render_schema_graphql() and render_env() methods to AutoSchemaHandlerTemplate struct
    • Add snapshot test for schema.graphql rendering
  • Updated callers:

    • init.rs: Replace HandleBarsDirGenerator with direct fs::write() calls to .env and package.json
    • contract_import_templates.rs: Replace HandleBarsDirGenerator with direct fs::write() calls and inline rendering methods
    • Remove unused get_dynamic_dir() and related methods from TemplateDirs
    • Remove Serialize derive from InitTemplates (no longer needed for Handlebars)
  • Cleanup:

    • Remove unused Handlebars test in system_config.rs
    • Remove tests for dynamic template directory access
    • Update module exports in hbs_templating/mod.rs

The new approach is more maintainable: template logic is now explicit Rust code with full type safety and IDE support, rather than scattered across template files and Handlebars helpers.

https://claude.ai/code/session_01Kt8L8CRc3wjfiSoyXaUFeZ

Summary by CodeRabbit

  • New Features

    • envio init now creates tailored .env and package.json files for ReScript and TypeScript projects.
    • Contract imports now generate schema.graphql files with event and field definitions.
    • .env files include clearer API token setup guidance or the provided token.
  • Refactor

    • Simplified project and contract-import template generation for more consistent output.
    • Removed support for dynamic template directories.

Replace the handlebars-based `.env`, `package.json`, and `schema.graphql`
templating with direct Rust string generation, matching the previous
rendered output byte-for-byte.

- Drop the `handlebars` crate and the `HandleBarsDirGenerator`.
- Delete the four `.hbs` templates (the whole `templates/dynamic` tree)
  and the now-dead template-dir plumbing that served them.
- Generate the shared `.env` via `env_template`, `package.json` via
  `InitTemplates`, and `schema.graphql` via `AutoSchemaHandlerTemplate`.
- Add unit/snapshot tests locking the generated output.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kt8L8CRc3wjfiSoyXaUFeZ
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cacd407c-cdf4-4221-8bca-0dbed9e17cad

📥 Commits

Reviewing files that changed from the base of the PR and between 9be0f58 and 7cf008a.

📒 Files selected for processing (1)
  • packages/cli/src/config_parsing/system_config.rs
📝 Walkthrough

Walkthrough

The CLI removes dynamic Handlebars template generation and renders initialization and contract-import files directly. New helpers generate .env, package.json, and GraphQL schema content, while template-directory APIs and related tests are removed or updated.

Changes

Direct template rendering

Layer / File(s) Summary
Remove dynamic Handlebars infrastructure
packages/cli/Cargo.toml, packages/cli/src/hbs_templating/*, packages/cli/src/template_dirs.rs, packages/cli/src/config_parsing/system_config.rs, packages/cli/templates/dynamic/*
Removes the Handlebars dependency, directory generator, dynamic template lookup, dynamic template files, and related tests and exports.
Add direct rendering helpers
packages/cli/src/hbs_templating/env_template.rs, packages/cli/src/hbs_templating/init_templates.rs
Adds .env and package.json rendering methods with snapshot tests.
Render initialization files directly
packages/cli/src/executor/init.rs
The init command renders and writes .env and package.json directly with contextual filesystem errors.
Render contract-import outputs directly
packages/cli/src/hbs_templating/contract_import_templates.rs, packages/cli/src/type_schema.rs
Contract import writes .env and computed GraphQL schema definitions directly; TypeIdent serializes as its stringified type, with EVM snapshot coverage.

Estimated code review effort: 4 (Complex) | ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing Handlebars-based template generation with direct string rendering.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

Convert the inline exact-string assertions for the generated `.env` and
`package.json` output to insta snapshots, matching the style already used
for `schema.graphql` and the codegen templates.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kt8L8CRc3wjfiSoyXaUFeZ
@DZakh
DZakh enabled auto-merge (squash) July 22, 2026 12:51
@DZakh
DZakh merged commit 2ef5bd1 into main Jul 22, 2026
8 checks passed
@DZakh
DZakh deleted the claude/handlebars-dependency-r1zj45 branch July 22, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants