Skip to content

Fix embedded template loading on Windows (templates_source path separators) - #75

Merged
lmorchard merged 1 commit into
mainfrom
fix-windows-embedded-templates
Jul 25, 2026
Merged

lmorchard merged 1 commit into
mainfrom
fix-windows-embedded-templates

Conversation

@lmorchard

Copy link
Copy Markdown
Owner

Problem

The post-merge cross-platform matrix for #73 failed on Windows-x86_64: the two new site_generator render tests panicked with Template '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 with PathBuf::join("templates"), which is \-delimited on Windows (default\templates). rust-embed always exposes /-delimited paths (default/templates/index.html), so starts_with matched nothing on Windows and the embedded-template fallback in templates::init returned an empty Tera.

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 of PathBuf. Add a platform-independent regression test asserting templates_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 test green 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

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>
@lmorchard
lmorchard merged commit 636f483 into main Jul 25, 2026
3 checks passed
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