Skip to content

Conversation

@chrisatbd
Copy link
Contributor

@chrisatbd chrisatbd commented Mar 14, 2025

Implement template loader.

  • Implements a template loader as described here issue 38
  • Unit Tests Added
  • Documentation updates

Checklist

  • I have read the contribution guidelines.
  • make test passes.
  • make lint passes.
  • New and changed code is covered by tests.
  • Performance improvements include benchmarks.
  • Changes match the documented (not just the implemented) behavior of Shopify.

chrisatbd and others added 2 commits March 13, 2025 17:11
@osteele osteele requested a review from Copilot May 21, 2025 06:46
Copy link
Contributor

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

Implements a pluggable template loader for custom storage backends and wires it through the engine and config, with tests and documentation updates.

  • Introduces an ITemplateStore interface and default FileTemplateStore
  • Updates Config and Engine to 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 I prefix. Consider renaming ITemplateStore to TemplateStore.
type ITemplateStore interface {

engine_test.go:167

  • [nitpick] Test function names should use CamelCase without underscores. Rename to TestTemplateStore for consistency with Go’s testing conventions.
func Test_template_store(t *testing.T) {

docs/TemplateStoreExample.md:20

  • The comment refers to ITemplateProvider but the interface is named ITemplateStore. Update to match the actual interface name.
//implementation of ITemplateProvider

values/drop_test.go:40

  • The benchmark loop for range b.N is invalid; b.N is an integer, not a slice or map. Revert to for i := 0; i < b.N; i++ {.
for range b.N {

values/drop_test.go:46

  • The benchmark loop for range b.N is invalid; use for i := 0; i < b.N; i++ { instead.
for range b.N {

values/drop_test.go:53

  • The benchmark loop for range b.N is invalid; replace with a standard for 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>
@danog
Copy link
Collaborator

danog commented Jun 1, 2025

Thanks!

@danog danog merged commit b6e3321 into osteele:main Jun 1, 2025
3 of 4 checks passed
@chrisatbd chrisatbd deleted the contribute/template-loader-2 branch June 3, 2025 20:12
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>
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.

2 participants