Fix embedded template loading on Windows (templates_source path separators) - #75
Merged
Merged
Conversation
templates_source built its filter/strip prefix with PathBuf::join, yielding a
`\`-delimited "default\templates" on Windows. rust-embed always uses
`/`-delimited paths, so nothing matched and no embedded templates loaded there —
`templates::init`'s embedded fallback returned an empty Tera and rendering
failed with "Template 'index.html' not found".
Operate on `/`-delimited strings instead (rust-embed's contract). Add a
platform-independent regression test asserting templates_source("default")
yields bare template names (index.html, day.html) with no prefix or separator.
Surfaced by the Windows CI matrix after #73, whose new site_generator render
tests are the first to exercise the embedded-template fallback on Windows.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The post-merge cross-platform matrix for #73 failed on Windows-x86_64: the two new
site_generatorrender tests panicked withTemplate 'index.html' not found.Root cause is a pre-existing latent bug in
templates_source(src/themes.rs), not the tests. It built its filter/strip prefix withPathBuf::join("templates"), which is\-delimited on Windows (default\templates). rust-embed always exposes/-delimited paths (default/templates/index.html), sostarts_withmatched nothing on Windows and the embedded-template fallback intemplates::initreturned an emptyTera.It never surfaced before because real Windows use goes through
init --customize(templates unpacked to disk → the filesystem branch). #73's render tests are the first to exercise the embedded fallback on Windows.Fix
Operate on
/-delimited strings (rust-embed's contract) instead ofPathBuf. Add a platform-independent regression test assertingtemplates_source("default")yields bare template names (index.html,day.html) with no leftover prefix or separator — the Windows matrix will now exercise it.Verification
make check+make testgreen locally (43 lib tests). Windows behavior will be confirmed by the post-merge matrix (PR checks only run Linux quick-test).🤖 Generated with Claude Code