Repository navigation
fix: default SourceLoader config.FS to LocalFS(/) (#5) - #6
Merged
Merged
Conversation
NewSourceLoader left config.FS nil when callers didn't set it, which broke
two scenarios:
1. Relative includes (e.g. `./Header.html`) inside templates escaped to the
process working directory. FSFolder.resolve fell back to NewLocalFS rooted
at the bare cwd string, so includes were searched under the process CWD
instead of the configured template root.
2. A local template and a @vendor-namespaced template sharing the same base
name (e.g. BasePage.html) collided on Template.Path, tripping Walker's
cycle guard and silently dropping the namespace load.
Default config.FS to NewLocalFS("/") when nil so absolute search paths and
vendor dirs resolve through one shared FS, loaded Paths are unique absolute
paths, and relative includes stay anchored under the template root.
Un-skips TestSourceLoader_RelativePathsInVendoredTemplates and adds
TestSourceLoader_LocalAndVendoredSameBasename to cover both regressions.
This was referenced Jun 19, 2026
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.
Summary
NewSourceLoadernow defaultsconfig.FStoNewLocalFS("/")when nil. Loaded templatePaths become absolute (no collision between local and vendored templates that share a basename) and relative includes resolve under the configured template root instead of the process CWD.TestSourceLoader_RelativePathsInVendoredTemplates(already covered case 1) and addsTestSourceLoader_LocalAndVendoredSameBasenamefor case 2.Reviewer's guide
source_loader.go— the only behavior change: nil-FS default inNewSourceLoader.NewSourceLoaderFromConfigalready resolves search paths to absolute, so they compose cleanly with a root-mounted LocalFS.vendoring_test.go— two tests exercising the fix paths.Test plan
go test -run 'TestSourceLoader_RelativePathsInVendoredTemplates|TestSourceLoader_LocalAndVendoredSameBasename' -v— both pass.go test -short ./...— full suite green.