Skip to content

Comments

Ensure template is recompiled when template file changes#65

Merged
casey merged 3 commits intomasterfrom
rebuild-on-change
Dec 2, 2025
Merged

Ensure template is recompiled when template file changes#65
casey merged 3 commits intomasterfrom
rebuild-on-change

Conversation

@casey
Copy link
Owner

@casey casey commented Dec 2, 2025

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the template reload mechanism to ensure automatic recompilation when template files change. Previously, templates were pre-parsed into tokens at macro expansion time, which meant changes to template files wouldn't trigger recompilation. The new approach stores the original template string using include_str!() for file-based templates, creating a compile-time dependency that Cargo tracks for automatic recompilation.

Key changes:

  • Replaced TOKENS constant with TEMPLATE constant storing the original template string
  • Split Parse error into ParseNew and ParseOld for clearer error messages
  • Template parsing now happens at runtime in the reload() method instead of at compile time

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/reload.rs Splits Parse error into ParseNew and ParseOld variants for better error context
src/lib.rs Replaces TOKENS const with TEMPLATE const; updates reload() to parse templates at runtime
crates/boilerplate-macros/src/template.rs Removes TOKENS generation logic; generates TEMPLATE const using Source's ToTokens impl
crates/boilerplate-macros/src/source.rs Implements ToTokens for Source, using include_str!() for file paths to enable automatic recompilation
crates/boilerplate-macros/src/lib.rs Adds ToTokens and TokenStreamExt imports needed for source.rs implementation
crates/boilerplate-macros/src/implementation.rs Removes unused tokens field from Implementation struct

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@casey casey enabled auto-merge (squash) December 2, 2025 22:40
@casey casey merged commit eaec826 into master Dec 2, 2025
4 checks passed
@casey casey deleted the rebuild-on-change branch December 2, 2025 22:41
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.

1 participant