-
Notifications
You must be signed in to change notification settings - Fork 56
update for fiber v3 #437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
update for fiber v3 #437
Conversation
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (2)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThis PR updates example imports from Fiber v2→v3, migrates many README code samples, centralizes binding normalization by adding AcquireViewContext(binding) (using reflection), and refactors template engines and tests to use the new helper instead of ad-hoc type switches. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Caller (app)
participant Engine as Template Engine
participant Acquire as AcquireViewContext
participant Reflection as reflect package
rect #E8F5E9
Note over Caller,Engine: New render flow uses centralized binding normalization
Caller->>Engine: Engine.Render(template, binding)
Engine->>Acquire: AcquireViewContext(binding)
end
alt binding == nil
Acquire-->>Engine: {}
else binding is map[string]interface{}
Acquire-->>Engine: same map
else pointer or map-like
Acquire->>Reflection: unwrap & iterate keys
Reflection-->>Acquire: validated map[string]interface{}
Acquire-->>Engine: populated map
else non-map
Acquire-->>Engine: {}
end
Engine->>Engine: render with normalized context
Engine-->>Caller: rendered output
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @ReneWerner87, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request performs a significant update to the Fiber template engine repository, primarily to align it with the new Fiber v3 release and the latest Go language version (1.25). The changes encompass updating module paths, Go version requirements, and a crucial refactoring of the data binding mechanism to enhance flexibility and reduce tight coupling with specific Fiber data structures. These updates ensure that the template engines are fully compatible and optimized for the Fiber v3 ecosystem. Highlights
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request updates the repository to use Fiber v3, which also involves a major version bump for the template library itself and its sub-packages. The changes include updating Go module paths, dependencies, and documentation. A significant and positive change is the refactoring to decouple template engines from fiber.Map by introducing a generic AcquireViewContext helper. I've found a few issues: the Go version is set to an unreleased version (1.25), there's an inconsistency in AcquireViewContext that could lead to side effects, and some minor formatting issues in the documentation. Overall, the changes are good, and with these fixes, the library will be in a much better state.
| module github.com/gofiber/template/ace/v3 | ||
|
|
||
| go 1.17 | ||
| go 1.25 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The go directive is set to 1.25, which is an unreleased version of Go. This will cause build failures for users on stable Go toolchains. The new code seems to require features from Go 1.22 (like reflect.MapRange), so the version should probably be 1.22. This change is needed in all go.mod files across the repository.
| go 1.25 | |
| go 1.22 |
|
|
||
| ### Installation | ||
| > Go version `1.17` or higher is required. | ||
| > Go version `1.25` or higher is required. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The required Go version is set to 1.25, which has not been released yet. This will cause confusion and prevent users from using this library with current stable Go versions. The new code uses reflect.MapRange, which was introduced in Go 1.22. I suggest setting the minimum required version to 1.22.
| > Go version `1.25` or higher is required. | |
| > Go version `1.22` or higher is required. |
| "log" | ||
|
|
||
| "github.com/gofiber/fiber/v2" | ||
| "github.com/gofiber/fiber/v3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation for this import seems to be using spaces instead of a tab, which is inconsistent with the surrounding code and what gofmt would produce. This makes the code block harder to read. This formatting issue is also present in other code examples in this file (e.g., lines 141, 166, 191).
| "github.com/gofiber/fiber/v3" | |
| "github.com/gofiber/fiber/v3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
django/django.go (1)
251-253: Compile fix: construct pongo2.Context, not map[string]interface{}.bind is pongo2.Context (a defined type). Assigning a plain map is a type mismatch.
- if bind == nil { - bind = make(map[string]interface{}, 1) - } + if bind == nil { + bind = make(pongo2.Context, 1) + }
🧹 Nitpick comments (7)
README.md (2)
52-61: Replace hard tabs in code blocks.markdownlint flags MD010; use spaces for alignment to keep linters green.
Also applies to: 142-143, 166-168, 191-193, 217-219
38-43: Add shell language label for syntax highlighting and confirm Go version requirement.Go 1.25 requirement is accurate per go.mod. Apply the suggested formatting change:
-``` +```sh go get -u github.com/gofiber/fiber/v3 go get -u github.com/gofiber/template/any_template_engine/vX</blockquote></details> <details> <summary>django/README.md (1)</summary><blockquote> `52-53`: **Remove tabs in import blocks.** MD010 warnings; switch to spaces for alignment. Also applies to: 108-110 </blockquote></details> <details> <summary>mustache/mustache.go (1)</summary><blockquote> `174-176`: **Nice simplification with AcquireViewContext.** Binding is normalized once, avoiding type switches. Consider preallocating capacity if desired: make(map[string]interface{}, len(bind)+1) when copying/augmenting elsewhere, but current code is fine. </blockquote></details> <details> <summary>template.go (2)</summary><blockquote> `136-139`: **Avoid mutating caller maps; copy when input is map[string]interface{}.** Returning the original map means downstream engines may add layout keys into the caller-provided map. Prefer copy-on-write to prevent side effects. Low cost vs. surprise bugs. ```diff - if binds, ok := binding.(map[string]interface{}); ok { - return binds - } + if binds, ok := binding.(map[string]interface{}); ok { + out := make(map[string]interface{}, len(binds)) + for k, v := range binds { + out[k] = v + } + return out + }
132-167: Add tests for edge cases.Please add unit tests covering: nil; empty map; pointer-to-map (nil and non-nil); user-defined map type with string keys; non-string key maps; pointer-to-pointer (ensure safe unwrap or fallback).
I can draft table-driven tests for AcquireViewContext if helpful.
django/django.go (1)
241-246: Don’t hold the engine lock across template execution.Locking around tmpl.Execute serializes all renders. Narrow the lock to only map lookups (e.Templates) and shared state reads. Execute outside the lock.
- // Lock while executing layout - e.Mutex.Lock() - defer e.Mutex.Unlock() - - bind := getPongoBinding(binding) - parsed, err := tmpl.Execute(bind) + bind := getPongoBinding(binding) + parsed, err := tmpl.Execute(bind) // execute without engine lock if err != nil { return err } ... - lay := e.Templates[layout[0]] + e.Mutex.RLock() + lay := e.Templates[layout[0]] + e.Mutex.RUnlock()Also applies to: 264-269
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (28)
.github/workflows/benchmark.ymlis excluded by!**/*.yml.github/workflows/golangci-lint.ymlis excluded by!**/*.yml.github/workflows/gosec.ymlis excluded by!**/*.yml.github/workflows/govulncheck.ymlis excluded by!**/*.yml.github/workflows/test-ace.ymlis excluded by!**/*.yml.github/workflows/test-amber.ymlis excluded by!**/*.yml.github/workflows/test-django.ymlis excluded by!**/*.yml.github/workflows/test-handlebars.ymlis excluded by!**/*.yml.github/workflows/test-html.ymlis excluded by!**/*.yml.github/workflows/test-jet.ymlis excluded by!**/*.yml.github/workflows/test-mustache.ymlis excluded by!**/*.yml.github/workflows/test-pug.ymlis excluded by!**/*.yml.github/workflows/test-slim.ymlis excluded by!**/*.ymlace/go.modis excluded by!**/*.modace/go.sumis excluded by!**/*.sum,!**/*.sumamber/go.modis excluded by!**/*.moddjango/go.modis excluded by!**/*.moddjango/go.sumis excluded by!**/*.sum,!**/*.sumgo.modis excluded by!**/*.modhandlebars/go.modis excluded by!**/*.modhandlebars/go.sumis excluded by!**/*.sum,!**/*.sumhtml/go.modis excluded by!**/*.modjet/go.modis excluded by!**/*.modjet/go.sumis excluded by!**/*.sum,!**/*.summustache/go.modis excluded by!**/*.modmustache/go.sumis excluded by!**/*.sum,!**/*.sumpug/go.modis excluded by!**/*.modslim/go.modis excluded by!**/*.mod
📒 Files selected for processing (23)
README.md(7 hunks)ace/README.md(1 hunks)ace/ace.go(1 hunks)amber/README.md(1 hunks)amber/amber.go(1 hunks)django/README.md(2 hunks)django/django.go(2 hunks)django/django_test.go(2 hunks)handlebars/README.md(1 hunks)handlebars/handlebars.go(2 hunks)handlebars/handlebars_test.go(6 hunks)html/README.md(3 hunks)html/html.go(1 hunks)jet/README.md(1 hunks)jet/jet.go(2 hunks)mustache/README.md(1 hunks)mustache/mustache.go(2 hunks)mustache/mustache_test.go(6 hunks)pug/README.md(1 hunks)pug/pug.go(1 hunks)slim/README.md(1 hunks)slim/slim.go(1 hunks)template.go(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
mustache/mustache.go (1)
template.go (1)
AcquireViewContext(136-167)
handlebars/handlebars.go (1)
template.go (1)
AcquireViewContext(136-167)
jet/jet.go (1)
template.go (1)
AcquireViewContext(136-167)
🪛 markdownlint-cli2 (0.18.1)
mustache/README.md
52-52: Hard tabs
Column: 1
(MD010, no-hard-tabs)
53-53: Hard tabs
Column: 1
(MD010, no-hard-tabs)
pug/README.md
47-47: Hard tabs
Column: 1
(MD010, no-hard-tabs)
48-48: Hard tabs
Column: 1
(MD010, no-hard-tabs)
amber/README.md
46-46: Hard tabs
Column: 1
(MD010, no-hard-tabs)
47-47: Hard tabs
Column: 1
(MD010, no-hard-tabs)
ace/README.md
46-46: Hard tabs
Column: 1
(MD010, no-hard-tabs)
47-47: Hard tabs
Column: 1
(MD010, no-hard-tabs)
handlebars/README.md
52-52: Hard tabs
Column: 1
(MD010, no-hard-tabs)
53-53: Hard tabs
Column: 1
(MD010, no-hard-tabs)
django/README.md
52-52: Hard tabs
Column: 1
(MD010, no-hard-tabs)
53-53: Hard tabs
Column: 1
(MD010, no-hard-tabs)
README.md
40-40: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
54-54: Hard tabs
Column: 1
(MD010, no-hard-tabs)
55-55: Hard tabs
Column: 1
(MD010, no-hard-tabs)
56-56: Hard tabs
Column: 1
(MD010, no-hard-tabs)
57-57: Hard tabs
Column: 1
(MD010, no-hard-tabs)
59-59: Hard tabs
Column: 1
(MD010, no-hard-tabs)
60-60: Hard tabs
Column: 1
(MD010, no-hard-tabs)
142-142: Hard tabs
Column: 1
(MD010, no-hard-tabs)
167-167: Hard tabs
Column: 1
(MD010, no-hard-tabs)
192-192: Hard tabs
Column: 1
(MD010, no-hard-tabs)
217-217: Hard tabs
Column: 1
(MD010, no-hard-tabs)
218-218: Hard tabs
Column: 1
(MD010, no-hard-tabs)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Compare
🔇 Additional comments (16)
pug/pug.go (1)
15-15: LGTM! Import path updated to v2.The core template import has been correctly updated to use the v2 module path, maintaining compatibility with the broader template package version upgrade.
html/html.go (1)
13-13: LGTM! Import path updated to v2.The core template import has been correctly updated to use the v2 module path.
slim/slim.go (1)
13-13: LGTM! Import path updated to v2.The core template import has been correctly updated to use the v2 module path.
handlebars/handlebars_test.go (2)
14-14: LGTM! Decoupling tests from Fiber types.Introducing
customMapas a local type alias removes the dependency onfiber.Mapin tests, allowing the template engine to be tested independently. This is a good practice for unit testing.
30-32: LGTM! Consistent test updates.All test cases have been consistently updated to use
customMapinstead offiber.Map, maintaining test coverage while decoupling from Fiber framework types.Also applies to: 41-43, 57-59, 73-75, 90-92
handlebars/handlebars.go (2)
13-13: LGTM! Import path updated to v2.The core template import has been correctly updated to use the v2 module path.
158-159: LGTM! Centralized binding normalization.Using
core.AcquireViewContext(binding)replaces manual type-switching logic with a centralized helper that normalizes various binding inputs (maps, pointers, nil values). This reduces code duplication and ensures consistent binding handling across template engines.mustache/mustache_test.go (2)
14-14: LGTM! Decoupling tests from Fiber types.Introducing
customMapremoves the dependency onfiber.Map, allowing independent testing of the template engine.
30-32: LGTM! Consistent test updates.All test cases have been consistently updated to use
customMap, maintaining test coverage while decoupling from Fiber framework types.Also applies to: 41-43, 57-59, 73-75, 89-91
mustache/README.md (1)
52-53: The version concern is incorrect; ignore the version-related verification request.The README example correctly references
github.com/gofiber/template/mustache/v3because the mustache module is versioned as v3 (permustache/go.mod). The implementation's use ofgithub.com/gofiber/template/v2is also correct—it references the core template module, which is versioned as v2 at the monorepo root. These are two different modules in the same repository with intentionally different versions.The formatting issue is valid: the import section uses hard tabs (
^Iincat -Aoutput) and should use spaces for consistency.Likely an incorrect or invalid review comment.
django/django_test.go (1)
120-123: Good replacement for fiber.Map in tests.Using a local custom map type validates the new binding normalization path without pulling Fiber as a test dep. LGTM.
django/README.md (1)
52-54: Verified: django/v4 module path is correctly published and referenced.The django/go.mod file declares
module github.com/gofiber/template/django/v4, and the import in django/README.md lines 52-54 correctly references"github.com/gofiber/template/django/v4". The module path is published and properly configured.README.md (1)
13-15: Remove suggestion to update badge target to v3—template/v3 does not exist.The badge correctly targets template/v2. The gofiber/template package documentation shows instructions like "go get -u github.com/gofiber/template/any_template_engine/vX", and Fiber v3 documentation explicitly uses template/html/v2. Only template subpackages (such as django/v3) have v3 variants; a v3 root package does not exist on pkg.go.dev. The current badge pointing to template/v2 aligns with official Fiber documentation and is the intended version.
jet/jet.go (1)
14-14: No action required—core import version is intentional and correct.The import of
core "github.com/gofiber/template/v2"in jet/jet.go (v3 engine) is by design. The jet/go.mod explicitly requiresgithub.com/gofiber/template/v2 v2.0.0with a replace directive pointing to the root module. All engines (v3 and v4) follow this same pattern: they wrap core v2 with engine-specific major versions. This is not a mixed-major-version surprise but a well-structured multi-module architecture.django/django.go (2)
162-188: Binding normalization + key sanitization look good.The reflective map handling and sanitizePongoContext correctly accept string-key maps (incl. custom types) and filter invalid identifiers.
Consider adding tests for: pongo2.Context passthrough; map[string]interface{}; custom map type; non-map inputs; invalid keys; nil map.
Also applies to: 190-203
14-15: Version mismatch concern is invalid; no changes required.The import of
github.com/gofiber/template/v2is correct and intentional. This monorepo structure separates the core template library (v2) from specific template engine bindings (django/v4, html/v3, etc.). The django package module is v4 (the binding version), while it correctly depends on the core template/v2 library—confirmed by the explicitrequireandreplacedirectives indjango/go.mod. The code and updated documentation are aligned.Likely an incorrect or invalid review comment.
| "github.com/gofiber/fiber/v3" | ||
| "github.com/gofiber/template/ace/v3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify version consistency across documentation and implementation.
The README example references github.com/gofiber/fiber/v3 and github.com/gofiber/template/ace/v3, but the actual template engine implementations in this PR (pug.go, html.go, slim.go) import github.com/gofiber/template/v2. Please confirm:
- Does
ace/v3exist and is it compatible with thetemplate/v2core used by other engines? - Should the documentation reference v3 while the implementations remain on v2?
Additionally, replace hard tabs with spaces on these lines to comply with markdown formatting standards.
Apply this diff to fix the indentation:
import (
- "log"
-
- "github.com/gofiber/fiber/v3"
- "github.com/gofiber/template/ace/v3"
+ "log"
+
+ "github.com/gofiber/fiber/v3"
+ "github.com/gofiber/template/ace/v3"
)I need to examine the codebase to verify the concerns raised in the review comment. Let me investigate the actual imports and file structure.
🏁 Script executed:
#!/bin/bash
# Find and examine template engine implementation files
echo "=== Searching for template engine files ==="
fd -e go -path "*template*" | head -20
echo ""
echo "=== Examining ace directory structure ==="
fd -type f "ace" | head -20
echo ""
echo "=== Looking for implementation files (pug.go, html.go, slim.go, ace.go) ==="
fd "(pug|html|slim|ace)\.go$"
echo ""
echo "=== Checking ace/README.md content ==="
fd "README.md" -path "*ace*" -exec cat {} \;
echo ""
echo "=== Examining actual imports in template files ==="
if [ -f "pug.go" ]; then echo "=== pug.go ==="; grep -A5 "^import" pug.go; fi
if [ -f "html.go" ]; then echo "=== html.go ==="; grep -A5 "^import" html.go; fi
if [ -f "slim.go" ]; then echo "=== slim.go ==="; grep -A5 "^import" slim.go; fi
if [ -f "ace.go" ]; then echo "=== ace.go ==="; grep -A5 "^import" ace.go; fiLength of output: 812
🏁 Script executed:
#!/bin/bash
echo "=== ace/ace.go imports ==="
cat ace/ace.go | grep -A10 "^import"
echo ""
echo "=== html/html.go imports ==="
cat html/html.go | grep -A10 "^import"
echo ""
echo "=== pug/pug.go imports ==="
cat pug/pug.go | grep -A10 "^import"
echo ""
echo "=== slim/slim.go imports ==="
cat slim/slim.go | grep -A10 "^import"
echo ""
echo "=== ace/README.md lines 40-55 ==="
cat ace/README.md | sed -n '40,55p'
echo ""
echo "=== Checking for tabs in ace/README.md lines 46-47 ==="
cat ace/README.md | sed -n '46,47p' | od -c | head -20Length of output: 1018
🏁 Script executed:
#!/bin/bash
echo "=== Detailed view of ace/README.md lines 44-50 ==="
sed -n '44,50p' ace/README.md | cat -A
echo ""
echo "=== Full pug/pug.go imports section ==="
cat pug/pug.go | head -30Length of output: 662
🌐 Web query:
gofiber template ace v3 compatibility
💡 Result:
Short answer: There is no official github.com/gofiber/template/ace/v3 package — the Ace wrapper is published as v2. So there isn’t an official "ace v3" release to match Fiber v3; use github.com/gofiber/template/ace/v2 (or embed a compatible Ace engine) and the Fiber Views interface instead. Sources: Fiber template docs (Ace examples using ace/v2) and the gofiber/template listing. [1][2]
References
- Ace wrapper example (ace/v2). [1]
- gofiber/template package / supported engines listing. [2]
Update README.md to fix version inconsistency and formatting.
The version mismatch is confirmed: all template implementations (ace, html, slim) import github.com/gofiber/template/v2, but the README example references the non-existent github.com/gofiber/template/ace/v3. Change to ace/v2. Additionally, lines 46–47 contain literal tabs that should be spaces per markdown standards.
import (
- "log"
-
- "github.com/gofiber/fiber/v3"
- "github.com/gofiber/template/ace/v3"
+ "log"
+
+ "github.com/gofiber/fiber/v3"
+ "github.com/gofiber/template/ace/v2"
)🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
46-46: Hard tabs
Column: 1
(MD010, no-hard-tabs)
47-47: Hard tabs
Column: 1
(MD010, no-hard-tabs)
🤖 Prompt for AI Agents
In ace/README.md around lines 46–47, the README shows an incorrect import and
contains literal tabs; update the import path from
github.com/gofiber/template/ace/v3 to github.com/gofiber/template/ace/v2 to
match the rest of the templates, and replace any literal tab characters on those
lines with spaces to conform to Markdown formatting standards.
| "github.com/gofiber/fiber/v3" | ||
| "github.com/gofiber/template/amber/v3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indentation: replace hard tabs with spaces.
The code block uses hard tabs for indentation, which is inconsistent with Markdown best practices.
Apply this diff to fix the indentation:
import (
- "log"
-
- "github.com/gofiber/fiber/v3"
- "github.com/gofiber/template/amber/v3"
+ "log"
+
+ "github.com/gofiber/fiber/v3"
+ "github.com/gofiber/template/amber/v3"
)Committable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
46-46: Hard tabs
Column: 1
(MD010, no-hard-tabs)
47-47: Hard tabs
Column: 1
(MD010, no-hard-tabs)
🤖 Prompt for AI Agents
In amber/README.md around lines 46 to 47, the code block contains hard tab
characters for indentation; replace those tabs with spaces (use consistent
indentation, e.g., 4 spaces per tab) so the Markdown code block uses spaces
only, and ensure no other tab characters remain in that block to maintain
consistent formatting.
| "github.com/gofiber/fiber/v3" | ||
| "github.com/gofiber/template/handlebars/v3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indentation: replace hard tabs with spaces.
The code block uses hard tabs for indentation, which is inconsistent with Markdown best practices.
Apply this diff to fix the indentation:
import (
- "log"
-
- "github.com/gofiber/fiber/v3"
- "github.com/gofiber/template/handlebars/v3"
+ "log"
+
+ "github.com/gofiber/fiber/v3"
+ "github.com/gofiber/template/handlebars/v3"
)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "github.com/gofiber/fiber/v3" | |
| "github.com/gofiber/template/handlebars/v3" | |
| import ( | |
| "log" | |
| "github.com/gofiber/fiber/v3" | |
| "github.com/gofiber/template/handlebars/v3" | |
| ) |
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
52-52: Hard tabs
Column: 1
(MD010, no-hard-tabs)
53-53: Hard tabs
Column: 1
(MD010, no-hard-tabs)
🤖 Prompt for AI Agents
In handlebars/README.md around lines 52 to 53 the fenced code block uses hard
tabs for indentation; replace those hard tab characters with spaces (use 4
spaces per indent) so the lines containing "github.com/gofiber/fiber/v3" and
"github.com/gofiber/template/handlebars/v3" are indented with spaces instead of
tabs, then save the file.
| func jetVarMap(binding interface{}) jet.VarMap { | ||
| var bind jet.VarMap | ||
| if binding == nil { | ||
| return nil | ||
| } | ||
|
|
||
| if bind, ok := binding.(jet.VarMap); ok { | ||
| return bind | ||
| } | ||
| switch binds := binding.(type) { | ||
| case map[string]interface{}: | ||
| bind = make(jet.VarMap) | ||
| for key, value := range binds { | ||
| bind.Set(key, value) | ||
| } | ||
| case fiber.Map: | ||
| bind = make(jet.VarMap) | ||
| for key, value := range binds { | ||
| bind.Set(key, value) | ||
| } | ||
| case jet.VarMap: | ||
| bind = binds | ||
|
|
||
| data := core.AcquireViewContext(binding) | ||
| bind := make(jet.VarMap) | ||
| for key, value := range data { | ||
| bind.Set(key, value) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nil binding + layout can panic; always return a non-nil VarMap.
bind.Set(...) on a nil VarMap will panic when a layout is used. Ensure jetVarMap never returns nil.
Apply:
-func jetVarMap(binding interface{}) jet.VarMap {
- if binding == nil {
- return nil
- }
-
- if bind, ok := binding.(jet.VarMap); ok {
- return bind
- }
-
- data := core.AcquireViewContext(binding)
- bind := make(jet.VarMap)
- for key, value := range data {
- bind.Set(key, value)
- }
- return bind
-}
+func jetVarMap(binding interface{}) jet.VarMap {
+ // Fast path: already a VarMap
+ if bind, ok := binding.(jet.VarMap); ok {
+ return bind
+ }
+ // Normalize any map-like binding (including nil) to a map[string]interface{}
+ data := core.AcquireViewContext(binding)
+ vm := make(jet.VarMap, len(data)+1) // +1 for potential layout insertion
+ for k, v := range data {
+ vm.Set(k, v)
+ }
+ return vm
+}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| func jetVarMap(binding interface{}) jet.VarMap { | |
| var bind jet.VarMap | |
| if binding == nil { | |
| return nil | |
| } | |
| if bind, ok := binding.(jet.VarMap); ok { | |
| return bind | |
| } | |
| switch binds := binding.(type) { | |
| case map[string]interface{}: | |
| bind = make(jet.VarMap) | |
| for key, value := range binds { | |
| bind.Set(key, value) | |
| } | |
| case fiber.Map: | |
| bind = make(jet.VarMap) | |
| for key, value := range binds { | |
| bind.Set(key, value) | |
| } | |
| case jet.VarMap: | |
| bind = binds | |
| data := core.AcquireViewContext(binding) | |
| bind := make(jet.VarMap) | |
| for key, value := range data { | |
| bind.Set(key, value) | |
| } | |
| func jetVarMap(binding interface{}) jet.VarMap { | |
| // Fast path: already a VarMap | |
| if bind, ok := binding.(jet.VarMap); ok { | |
| return bind | |
| } | |
| // Normalize any map-like binding (including nil) to a map[string]interface{} | |
| data := core.AcquireViewContext(binding) | |
| vm := make(jet.VarMap, len(data)+1) // +1 for potential layout insertion | |
| for k, v := range data { | |
| vm.Set(k, v) | |
| } | |
| return vm | |
| } |
🤖 Prompt for AI Agents
In jet/jet.go around lines 192 to 205, the function jetVarMap can return nil (or
leave bind nil) which causes bind.Set(...) to panic when used by a layout;
change the function to always return a non-nil jet.VarMap: when binding == nil
return make(jet.VarMap) (not nil), when binding already a jet.VarMap return it
as-is, and when constructing from core.AcquireViewContext always initialize bind
:= make(jet.VarMap) and return bind at the end so the function never returns
nil.
| "github.com/gofiber/fiber/v3" | ||
| "github.com/gofiber/template/pug/v3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix indentation: replace hard tabs with spaces.
The code block uses hard tabs for indentation, which is inconsistent with Markdown best practices.
Apply this diff to fix the indentation:
import (
- "log"
+ "log"
- "github.com/gofiber/fiber/v3"
- "github.com/gofiber/template/pug/v3"
+ "github.com/gofiber/fiber/v3"
+ "github.com/gofiber/template/pug/v3"
- // "net/http" // embedded system
+ // "net/http" // embedded system
)Committable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
47-47: Hard tabs
Column: 1
(MD010, no-hard-tabs)
48-48: Hard tabs
Column: 1
(MD010, no-hard-tabs)
🤖 Prompt for AI Agents
In pug/README.md around lines 47 to 48, the code block uses hard tab characters
for indentation; replace those tabs with spaces (preferably 2 spaces per indent
or match repository style) so the Markdown code block uses spaces instead of
hard tabs, ensuring consistent indentation across the file and saving the file
without tab characters in that block.
| val := reflect.ValueOf(binding) | ||
| if val.Kind() == reflect.Pointer { | ||
| if val.IsNil() { | ||
| return make(map[string]interface{}) | ||
| } | ||
| val = val.Elem() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compile fix: use reflect.Ptr (not reflect.Pointer).
reflect.Kind uses Ptr. Current code won’t compile.
- if val.Kind() == reflect.Pointer {
+ if val.Kind() == reflect.Ptr {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| val := reflect.ValueOf(binding) | |
| if val.Kind() == reflect.Pointer { | |
| if val.IsNil() { | |
| return make(map[string]interface{}) | |
| } | |
| val = val.Elem() | |
| } | |
| val := reflect.ValueOf(binding) | |
| if val.Kind() == reflect.Ptr { | |
| if val.IsNil() { | |
| return make(map[string]interface{}) | |
| } | |
| val = val.Elem() | |
| } |
🤖 Prompt for AI Agents
In template.go around lines 145 to 151, the code checks reflect.Kind using the
non-existent constant reflect.Pointer which causes a compile error; change the
check to use reflect.Ptr, ensure the Nil and Elem logic remains the same (i.e.,
if val.Kind() == reflect.Ptr { if val.IsNil() { return
make(map[string]interface{}) } val = val.Elem() }) so the code compiles and
handles nil pointers correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (10)
handlebars/README.md (1)
52-53: ** Fix indentation: replace hard tabs with spaces.**This Markdown formatting issue has already been flagged in previous reviews. Replace hard tabs with spaces throughout the code block.
import ( - "log" - - "github.com/gofiber/fiber/v3" - "github.com/gofiber/template/handlebars/v3" + "log" + + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/handlebars/v3" ) - app.Get("/", func(c fiber.Ctx) error { - // Render index - return c.Render("index", fiber.Map{ - "Title": "Hello, World!", - }) - }) - - app.Get("/layout", func(c fiber.Ctx) error { + app.Get("/", func(c fiber.Ctx) error { + // Render index + return c.Render("index", fiber.Map{ + "Title": "Hello, World!", + }) + }) + + app.Get("/layout", func(c fiber.Ctx) error {Also applies to: 69-74
mustache/README.md (1)
52-53: ** Fix indentation: replace hard tabs with spaces.**Same Markdown formatting issue as other engine READMEs. Replace hard tabs with spaces.
import ( - "log" - - "github.com/gofiber/fiber/v3" - "github.com/gofiber/template/mustache/v3" + "log" + + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/mustache/v3" ) - app.Get("/", func(c fiber.Ctx) error { - // Render index - return c.Render("index", fiber.Map{ - "Title": "Hello, World!", - }) - }) - - app.Get("/layout", func(c fiber.Ctx) error { + app.Get("/", func(c fiber.Ctx) error { + // Render index + return c.Render("index", fiber.Map{ + "Title": "Hello, World!", + }) + }) + + app.Get("/layout", func(c fiber.Ctx) error {Also applies to: 70-82
ace/README.md (2)
46-47: ** Fix indentation: replace hard tabs with spaces.**Replace hard tabs with spaces in import block and route handlers.
import ( - "log" - - "github.com/gofiber/fiber/v3" - "github.com/gofiber/template/ace/v2" + "log" + + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/ace/v2" ) - app.Get("/", func(c fiber.Ctx) error { - // Render index - return c.Render("index", fiber.Map{ - "Title": "Hello, World!", - }) - }) - - app.Get("/layout", func(c fiber.Ctx) error { + app.Get("/", func(c fiber.Ctx) error { + // Render index + return c.Render("index", fiber.Map{ + "Title": "Hello, World!", + }) + }) + + app.Get("/layout", func(c fiber.Ctx) error {Also applies to: 63-75
46-47: Version mismatch:ace/v3does not exist—useace/v2.A previous review verified that there is no official
github.com/gofiber/template/ace/v3package; the Ace engine remains on v2. Update the import to match the actual module path.import ( - "github.com/gofiber/fiber/v3" - "github.com/gofiber/template/ace/v3" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/ace/v2"amber/README.md (1)
46-47: ** Fix indentation: replace hard tabs with spaces.**Markdown formatting: replace hard tabs with spaces.
import ( - "log" - - "github.com/gofiber/fiber/v3" - "github.com/gofiber/template/amber/v3" + "log" + + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/amber/v3" ) - app.Get("/", func(c fiber.Ctx) error { - // Render index - return c.Render("index", fiber.Map{ - "Title": "Hello, World!", - }) - }) - - app.Get("/layout", func(c fiber.Ctx) error { + app.Get("/", func(c fiber.Ctx) error { + // Render index + return c.Render("index", fiber.Map{ + "Title": "Hello, World!", + }) + }) + + app.Get("/layout", func(c fiber.Ctx) error {Also applies to: 63-75
pug/README.md (1)
47-48: ** Fix indentation: replace hard tabs with spaces.**Markdown formatting issue: replace hard tabs with spaces in import and route handler blocks.
import ( - "log" - - "github.com/gofiber/fiber/v3" - "github.com/gofiber/template/pug/v3" + "log" + + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/pug/v3" ) - app.Get("/", func(c fiber.Ctx) error { - // Render index - return c.Render("index", fiber.Map{ - "Title": "Hello, World!", - }) - }) - - app.Get("/layout", func(c fiber.Ctx) error { + app.Get("/", func(c fiber.Ctx) error { + // Render index + return c.Render("index", fiber.Map{ + "Title": "Hello, World!", + }) + }) + + app.Get("/layout", func(c fiber.Ctx) error {Also applies to: 66-78
slim/README.md (1)
47-48: ** Fix indentation: replace hard tabs with spaces.**Markdown formatting issue: replace hard tabs with spaces throughout the code block.
import ( - "log" - - "github.com/gofiber/fiber/v3" - "github.com/gofiber/template/slim/v3" + "log" + + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/slim/v3" ) - app.Get("/", func(c fiber.Ctx) error { - // Render index - return c.Render("index", fiber.Map{ - "Title": "Hello, World!", - }) - }) - - app.Get("/layout", func(c fiber.Ctx) error { + app.Get("/", func(c fiber.Ctx) error { + // Render index + return c.Render("index", fiber.Map{ + "Title": "Hello, World!", + }) + }) + + app.Get("/layout", func(c fiber.Ctx) error {Also applies to: 66-78
html/README.md (1)
63-64: ** Fix indentation: replace hard tabs with spaces.**Multiple code blocks use hard tabs; replace with spaces for Markdown compliance.
import ( - "log" - - "github.com/gofiber/fiber/v3" - "github.com/gofiber/template/html/v3" + "log" + + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/html/v3" ) - app.Get("/", func(c fiber.Ctx) error { - // Render index - return c.Render("index", fiber.Map{ - "Title": "Hello, World!", - }) - }) - - app.Get("/layout", func(c fiber.Ctx) error { - // Render index within layouts/main - return c.Render("index", fiber.Map{ - "Title": "Hello, World!", - }, "layouts/main") - }) - - app.Get("/layouts-nested", func(c fiber.Ctx) error { + app.Get("/", func(c fiber.Ctx) error { + // Render index + return c.Render("index", fiber.Map{ + "Title": "Hello, World!", + }) + }) + + app.Get("/layout", func(c fiber.Ctx) error { + // Render index within layouts/main + return c.Render("index", fiber.Map{ + "Title": "Hello, World!", + }, "layouts/main") + }) + + app.Get("/layouts-nested", func(c fiber.Ctx) error {Apply similar formatting fixes to other code examples (lines 116–117, 166–167, 185–190).
Also applies to: 80-85, 87-92, 116-117, 166-167, 185-190
README.md (2)
52-52: ** Fix indentation: replace hard tabs with spaces.**Multiple code examples use hard tabs instead of spaces. Replace tabs with spaces for Markdown compliance (MD010).
Also applies to: 141-141, 166-166, 191-191, 217-217
38-38: Go version requirement1.25is unreleased—use1.22.Go 1.25 has not been released. A previous review identified this and noted that
reflect.MapRange(required by the code) was added in Go 1.22. Update the requirement to reflect the actual minimum.-> Go version `1.22` or higher is required.
🧹 Nitpick comments (1)
README.md (1)
13-13: Consider updating documentation link to v3.The godoc badge links to
/v2?tab=doc, but the PR upgrades to v3. Verify whether the link should be updated to/v3?tab=docfor consistency.- <a href="https://pkg.go.dev/github.com/gofiber/template/v2?tab=doc"> + <a href="https://pkg.go.dev/github.com/gofiber/template/v3?tab=doc">
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
README.md(8 hunks)ace/README.md(2 hunks)amber/README.md(2 hunks)django/README.md(4 hunks)handlebars/README.md(2 hunks)html/README.md(6 hunks)jet/README.md(2 hunks)mustache/README.md(2 hunks)pug/README.md(2 hunks)slim/README.md(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- jet/README.md
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
html/README.md
63-63: Hard tabs
Column: 1
(MD010, no-hard-tabs)
64-64: Hard tabs
Column: 1
(MD010, no-hard-tabs)
80-80: Hard tabs
Column: 1
(MD010, no-hard-tabs)
81-81: Hard tabs
Column: 1
(MD010, no-hard-tabs)
82-82: Hard tabs
Column: 1
(MD010, no-hard-tabs)
83-83: Hard tabs
Column: 1
(MD010, no-hard-tabs)
84-84: Hard tabs
Column: 1
(MD010, no-hard-tabs)
85-85: Hard tabs
Column: 1
(MD010, no-hard-tabs)
87-87: Hard tabs
Column: 1
(MD010, no-hard-tabs)
88-88: Hard tabs
Column: 1
(MD010, no-hard-tabs)
89-89: Hard tabs
Column: 1
(MD010, no-hard-tabs)
90-90: Hard tabs
Column: 1
(MD010, no-hard-tabs)
91-91: Hard tabs
Column: 1
(MD010, no-hard-tabs)
92-92: Hard tabs
Column: 1
(MD010, no-hard-tabs)
94-94: Hard tabs
Column: 1
(MD010, no-hard-tabs)
README.md
52-52: Hard tabs
Column: 1
(MD010, no-hard-tabs)
58-58: Hard tabs
Column: 1
(MD010, no-hard-tabs)
59-59: Hard tabs
Column: 1
(MD010, no-hard-tabs)
60-60: Hard tabs
Column: 1
(MD010, no-hard-tabs)
ace/README.md
64-64: Hard tabs
Column: 1
(MD010, no-hard-tabs)
65-65: Hard tabs
Column: 1
(MD010, no-hard-tabs)
66-66: Hard tabs
Column: 1
(MD010, no-hard-tabs)
67-67: Hard tabs
Column: 1
(MD010, no-hard-tabs)
69-69: Hard tabs
Column: 1
(MD010, no-hard-tabs)
70-70: Hard tabs
Column: 1
(MD010, no-hard-tabs)
handlebars/README.md
52-52: Hard tabs
Column: 1
(MD010, no-hard-tabs)
53-53: Hard tabs
Column: 1
(MD010, no-hard-tabs)
69-69: Hard tabs
Column: 1
(MD010, no-hard-tabs)
70-70: Hard tabs
Column: 1
(MD010, no-hard-tabs)
71-71: Hard tabs
Column: 1
(MD010, no-hard-tabs)
72-72: Hard tabs
Column: 1
(MD010, no-hard-tabs)
73-73: Hard tabs
Column: 1
(MD010, no-hard-tabs)
74-74: Hard tabs
Column: 1
(MD010, no-hard-tabs)
76-76: Hard tabs
Column: 1
(MD010, no-hard-tabs)
mustache/README.md
52-52: Hard tabs
Column: 1
(MD010, no-hard-tabs)
53-53: Hard tabs
Column: 1
(MD010, no-hard-tabs)
70-70: Hard tabs
Column: 1
(MD010, no-hard-tabs)
71-71: Hard tabs
Column: 1
(MD010, no-hard-tabs)
72-72: Hard tabs
Column: 1
(MD010, no-hard-tabs)
73-73: Hard tabs
Column: 1
(MD010, no-hard-tabs)
74-74: Hard tabs
Column: 1
(MD010, no-hard-tabs)
75-75: Hard tabs
Column: 1
(MD010, no-hard-tabs)
77-77: Hard tabs
Column: 1
(MD010, no-hard-tabs)
pug/README.md
66-66: Hard tabs
Column: 1
(MD010, no-hard-tabs)
67-67: Hard tabs
Column: 1
(MD010, no-hard-tabs)
69-69: Hard tabs
Column: 1
(MD010, no-hard-tabs)
70-70: Hard tabs
Column: 1
(MD010, no-hard-tabs)
71-71: Hard tabs
Column: 1
(MD010, no-hard-tabs)
72-72: Hard tabs
Column: 1
(MD010, no-hard-tabs)
73-73: Hard tabs
Column: 1
(MD010, no-hard-tabs)
slim/README.md
47-47: Hard tabs
Column: 1
(MD010, no-hard-tabs)
48-48: Hard tabs
Column: 1
(MD010, no-hard-tabs)
66-66: Hard tabs
Column: 1
(MD010, no-hard-tabs)
67-67: Hard tabs
Column: 1
(MD010, no-hard-tabs)
68-68: Hard tabs
Column: 1
(MD010, no-hard-tabs)
69-69: Hard tabs
Column: 1
(MD010, no-hard-tabs)
70-70: Hard tabs
Column: 1
(MD010, no-hard-tabs)
71-71: Hard tabs
Column: 1
(MD010, no-hard-tabs)
73-73: Hard tabs
Column: 1
(MD010, no-hard-tabs)
🔇 Additional comments (2)
django/README.md (2)
46-86: Example code correctly updated to Fiber v3.The imports and handler signatures are properly updated and consistent with Fiber v3 conventions. Code is syntactically correct and complete.
100-134: Embedded filesystem example correctly updated to Fiber v3.The embedded filesystem example maintains proper structure with correct v3 imports and handler signatures. The
//go:embeddirective andNewPathForwardingFileSystemusage are appropriate.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68f20eafcc0483268698654a89a5a918
Summary by CodeRabbit
New Features
Chores
Tests