Implement template loader - #107
Merged
Merged
Conversation
Implement template loader
Contributor
There was a problem hiding this comment.
Pull Request Overview
Implements a pluggable template loader for custom storage backends and wires it through the engine and config, with tests and documentation updates.
- Introduces an
ITemplateStoreinterface and defaultFileTemplateStore - Updates
ConfigandEngineto hold and register a template store - Adds unit tests, benchmarks updates, and usage examples in docs
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| values/drop_test.go | Benchmark loops incorrectly changed to for range b.N |
| render/file_template_store.go | New FileTemplateStore implementing ITemplateStore |
| render/context.go | Swaps os.ReadFile for TemplateStore.ReadTemplate |
| render/config.go | Adds TemplateStore field and defaults it in NewConfig |
| engine_test.go | Adds mock store test for RegisterTemplateStore |
| engine.go | Adds RegisterTemplateStore method |
| docs/TemplateStoreExample.md | Adds an embedded-FS example for ITemplateStore |
| README.md | Documents the new Template Store feature |
Comments suppressed due to low confidence (7)
render/context.go:58
- [nitpick] In Go idioms, interfaces typically don’t use an
Iprefix. Consider renamingITemplateStoretoTemplateStore.
type ITemplateStore interface {
engine_test.go:167
- [nitpick] Test function names should use CamelCase without underscores. Rename to
TestTemplateStorefor consistency with Go’s testing conventions.
func Test_template_store(t *testing.T) {
docs/TemplateStoreExample.md:20
- The comment refers to
ITemplateProviderbut the interface is namedITemplateStore. Update to match the actual interface name.
//implementation of ITemplateProvider
values/drop_test.go:40
- The benchmark loop
for range b.Nis invalid;b.Nis an integer, not a slice or map. Revert tofor i := 0; i < b.N; i++ {.
for range b.N {
values/drop_test.go:46
- The benchmark loop
for range b.Nis invalid; usefor i := 0; i < b.N; i++ {instead.
for range b.N {
values/drop_test.go:53
- The benchmark loop
for range b.Nis invalid; replace with a standardfor i := 0; i < b.N; i++ {.
for range b.N {
README.md:168
- The example call omits the required argument. Change to
engine.RegisterTemplateStore(embedFileSystemTemplateStore).
engine.RegisterTemplateStore()
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Collaborator
|
Thanks! |
osteele
pushed a commit
that referenced
this pull request
Nov 6, 2025
Updated CHANGELOG.md to include all merged PRs since version 1.3.0 (2020-02-13): Added features: - Jekyll Extensions Support (#114) - Auto-Escape Feature (#111) - Template Loader (#107) - BasicEngine (#104) - JSON Filter (#84) - Strict Variables Mode (#74) - Custom Writer Support (#86) - Template AST Access (#59, #66) - For-Else Support (#93) - Unless-Else Support (#68) - General Range Expressions (#65) - Loop Modifier Expressions (#67) Fixes: - Size filter, slice bounds, division by zero - Nil pointer handling - Whitespace control - Multiline slice - Block errors - Map filter with structs - And more Also added steve-ky as contributor for ideas/feedback on PR #89. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <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.
Implement template loader.
Checklist
make testpasses.make lintpasses.