From 83027db87162ae95b70afec2f32d92735580f57f Mon Sep 17 00:00:00 2001 From: RW Date: Fri, 17 Oct 2025 12:30:21 +0200 Subject: [PATCH 1/7] docs: update fiber imports to v3 --- .github/workflows/benchmark.yml | 2 +- .github/workflows/golangci-lint.yml | 2 +- .github/workflows/gosec.yml | 2 +- .github/workflows/govulncheck.yml | 78 +++++++++++++-------------- .github/workflows/test-ace.yml | 7 +-- .github/workflows/test-amber.yml | 7 +-- .github/workflows/test-django.yml | 6 +-- .github/workflows/test-handlebars.yml | 7 +-- .github/workflows/test-html.yml | 7 +-- .github/workflows/test-jet.yml | 7 +-- .github/workflows/test-mustache.yml | 7 +-- .github/workflows/test-pug.yml | 7 +-- .github/workflows/test-slim.yml | 7 +-- README.md | 30 +++++------ ace/README.md | 4 +- ace/ace.go | 2 +- ace/go.mod | 8 +-- ace/go.sum | 9 ---- amber/README.md | 4 +- amber/amber.go | 2 +- amber/go.mod | 8 +-- django/README.md | 8 +-- django/django.go | 53 +++++++++++------- django/django_test.go | 11 ++-- django/go.mod | 20 ++----- django/go.sum | 30 ++--------- go.mod | 4 +- handlebars/README.md | 4 +- handlebars/go.mod | 19 ++----- handlebars/go.sum | 25 --------- handlebars/handlebars.go | 14 +---- handlebars/handlebars_test.go | 14 ++--- html/README.md | 12 ++--- html/go.mod | 8 +-- html/html.go | 2 +- jet/README.md | 4 +- jet/go.mod | 20 ++----- jet/go.sum | 27 ---------- jet/jet.go | 27 ++++------ mustache/README.md | 4 +- mustache/go.mod | 19 ++----- mustache/go.sum | 25 --------- mustache/mustache.go | 16 +----- mustache/mustache_test.go | 14 ++--- pug/README.md | 4 +- pug/go.mod | 8 +-- pug/pug.go | 2 +- slim/README.md | 4 +- slim/go.mod | 8 +-- slim/slim.go | 2 +- template.go | 38 +++++++++++++ 51 files changed, 241 insertions(+), 418 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index f9444ac4..805c0e91 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -32,7 +32,7 @@ jobs: uses: actions/setup-go@v5 with: # NOTE: Keep this in sync with the version from go.mod - go-version: "1.20.x" + go-version: "1.25.x" cache: false - name: Run Benchmarks diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 204a32d8..34502039 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -34,7 +34,7 @@ jobs: uses: actions/setup-go@v5 with: # NOTE: Keep this in sync with the version from go.mod - go-version: '1.20.x' + go-version: '1.25.x' cache: false - name: golangci-lint uses: golangci/golangci-lint-action@v6 diff --git a/.github/workflows/gosec.yml b/.github/workflows/gosec.yml index eace6b8d..553afcd2 100644 --- a/.github/workflows/gosec.yml +++ b/.github/workflows/gosec.yml @@ -55,7 +55,7 @@ jobs: - name: Install Go uses: actions/setup-go@v5 with: - go-version: '^1.21.x' + go-version: '1.25.x' check-latest: true cache: false - name: Install gosec diff --git a/.github/workflows/govulncheck.yml b/.github/workflows/govulncheck.yml index 854ce3b2..ebf589cc 100644 --- a/.github/workflows/govulncheck.yml +++ b/.github/workflows/govulncheck.yml @@ -1,39 +1,39 @@ -name: Govulncheck Security Scan - -on: - push: - branches: - - "master" - - "main" - paths-ignore: - - "**.md" - - LICENSE - - ".github/ISSUE_TEMPLATE/*.yml" - - ".github/dependabot.yml" - pull_request: - branches: - - "*" - paths-ignore: - - "**.md" - - LICENSE - - ".github/ISSUE_TEMPLATE/*.yml" - - ".github/dependabot.yml" - -jobs: - govulncheck-check: - runs-on: ubuntu-latest - env: - GO111MODULE: on - steps: - - name: Fetch Repository - uses: actions/checkout@v5 - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: 'stable' - check-latest: true - cache: false - - name: Install Govulncheck - run: go install golang.org/x/vuln/cmd/govulncheck@latest - - name: Run Govulncheck - run: govulncheck ./... \ No newline at end of file +name: Govulncheck Security Scan + +on: + push: + branches: + - "master" + - "main" + paths-ignore: + - "**.md" + - LICENSE + - ".github/ISSUE_TEMPLATE/*.yml" + - ".github/dependabot.yml" + pull_request: + branches: + - "*" + paths-ignore: + - "**.md" + - LICENSE + - ".github/ISSUE_TEMPLATE/*.yml" + - ".github/dependabot.yml" + +jobs: + govulncheck-check: + runs-on: ubuntu-latest + env: + GO111MODULE: on + steps: + - name: Fetch Repository + uses: actions/checkout@v5 + - name: Install Go + uses: actions/setup-go@v5 + with: + go-version: '1.25.x' + check-latest: false + cache: false + - name: Install Govulncheck + run: go install golang.org/x/vuln/cmd/govulncheck@latest + - name: Run Govulncheck + run: govulncheck ./... diff --git a/.github/workflows/test-ace.yml b/.github/workflows/test-ace.yml index d401dd0b..c274c97c 100644 --- a/.github/workflows/test-ace.yml +++ b/.github/workflows/test-ace.yml @@ -16,12 +16,7 @@ jobs: strategy: matrix: go-version: - - 1.17.x - - 1.18.x - - 1.19.x - - 1.20.x - - 1.21.x - - 1.22.x + - 1.25.x platform: [ ubuntu-latest, windows-latest ] runs-on: ${{ matrix.platform }} steps: diff --git a/.github/workflows/test-amber.yml b/.github/workflows/test-amber.yml index 95890373..256fa1c8 100644 --- a/.github/workflows/test-amber.yml +++ b/.github/workflows/test-amber.yml @@ -16,12 +16,7 @@ jobs: strategy: matrix: go-version: - - 1.17.x - - 1.18.x - - 1.19.x - - 1.20.x - - 1.21.x - - 1.22.x + - 1.25.x platform: [ ubuntu-latest, windows-latest ] runs-on: ${{ matrix.platform }} steps: diff --git a/.github/workflows/test-django.yml b/.github/workflows/test-django.yml index 07e35cbf..b756dd48 100644 --- a/.github/workflows/test-django.yml +++ b/.github/workflows/test-django.yml @@ -16,11 +16,7 @@ jobs: strategy: matrix: go-version: - - 1.18.x - - 1.19.x - - 1.20.x - - 1.21.x - - 1.22.x + - 1.25.x platform: [ ubuntu-latest, windows-latest ] runs-on: ${{ matrix.platform }} steps: diff --git a/.github/workflows/test-handlebars.yml b/.github/workflows/test-handlebars.yml index b4997d25..b1e85581 100644 --- a/.github/workflows/test-handlebars.yml +++ b/.github/workflows/test-handlebars.yml @@ -16,12 +16,7 @@ jobs: strategy: matrix: go-version: - - 1.17.x - - 1.18.x - - 1.19.x - - 1.20.x - - 1.21.x - - 1.22.x + - 1.25.x platform: [ ubuntu-latest, windows-latest ] runs-on: ${{ matrix.platform }} steps: diff --git a/.github/workflows/test-html.yml b/.github/workflows/test-html.yml index 43096d35..7c7ce6cb 100644 --- a/.github/workflows/test-html.yml +++ b/.github/workflows/test-html.yml @@ -16,12 +16,7 @@ jobs: strategy: matrix: go-version: - - 1.17.x - - 1.18.x - - 1.19.x - - 1.20.x - - 1.21.x - - 1.22.x + - 1.25.x platform: [ ubuntu-latest, windows-latest ] runs-on: ${{ matrix.platform }} steps: diff --git a/.github/workflows/test-jet.yml b/.github/workflows/test-jet.yml index f508dd54..7b2763aa 100644 --- a/.github/workflows/test-jet.yml +++ b/.github/workflows/test-jet.yml @@ -16,12 +16,7 @@ jobs: strategy: matrix: go-version: - - 1.17.x - - 1.18.x - - 1.19.x - - 1.20.x - - 1.21.x - - 1.22.x + - 1.25.x platform: [ ubuntu-latest, windows-latest ] runs-on: ${{ matrix.platform }} steps: diff --git a/.github/workflows/test-mustache.yml b/.github/workflows/test-mustache.yml index c0cc1bdd..554226df 100644 --- a/.github/workflows/test-mustache.yml +++ b/.github/workflows/test-mustache.yml @@ -16,12 +16,7 @@ jobs: strategy: matrix: go-version: - - 1.17.x - - 1.18.x - - 1.19.x - - 1.20.x - - 1.21.x - - 1.22.x + - 1.25.x platform: [ ubuntu-latest, windows-latest ] runs-on: ${{ matrix.platform }} steps: diff --git a/.github/workflows/test-pug.yml b/.github/workflows/test-pug.yml index 575e28a1..a46536e5 100644 --- a/.github/workflows/test-pug.yml +++ b/.github/workflows/test-pug.yml @@ -16,12 +16,7 @@ jobs: strategy: matrix: go-version: - - 1.17.x - - 1.18.x - - 1.19.x - - 1.20.x - - 1.21.x - - 1.22.x + - 1.25.x platform: [ ubuntu-latest, windows-latest ] runs-on: ${{ matrix.platform }} steps: diff --git a/.github/workflows/test-slim.yml b/.github/workflows/test-slim.yml index bbd43f07..d9ab8395 100644 --- a/.github/workflows/test-slim.yml +++ b/.github/workflows/test-slim.yml @@ -16,12 +16,7 @@ jobs: strategy: matrix: go-version: - - 1.17.x - - 1.18.x - - 1.19.x - - 1.20.x - - 1.21.x - - 1.22.x + - 1.25.x platform: [ ubuntu-latest, windows-latest ] runs-on: ${{ matrix.platform }} steps: diff --git a/README.md b/README.md index f7bbaffc..b1ef808b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ sidebar_position: 1 Fiber
- + @@ -35,10 +35,10 @@ This package provides universal methods to use multiple template engines with th - [slim](./slim/README.md) ### Installation -> Go version `1.17` or higher is required. +> Go version `1.25` or higher is required. ``` -go get -u github.com/gofiber/fiber/v2 +go get -u github.com/gofiber/fiber/v3 go get -u github.com/gofiber/template/any_template_engine/vX ``` @@ -49,15 +49,15 @@ package main import ( "log" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" // To use a specific template engine, import as shown below: - // "github.com/gofiber/template/pug" - // "github.com/gofiber/template/mustache" + // "github.com/gofiber/template/pug/v3" + // "github.com/gofiber/template/mustache/v3" // etc.. // In this example we use the html template engine - "github.com/gofiber/template/html/v2" + "github.com/gofiber/template/html/v3" ) func main() { @@ -138,8 +138,8 @@ package main import ( "log" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/html" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/html/v3" "github.com/markbates/pkger" ) @@ -163,8 +163,8 @@ package main import ( "log" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/html" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/html/v3" "github.com/gobuffalo/packr/v2" ) @@ -188,8 +188,8 @@ package main import ( "log" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/html" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/html/v3" "github.com/GeertJohan/go.rice" ) @@ -214,8 +214,8 @@ package main import ( "log" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/html" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/html/v3" // your generated package "github.com///static" ) diff --git a/ace/README.md b/ace/README.md index 8303241a..87dded7b 100644 --- a/ace/README.md +++ b/ace/README.md @@ -43,8 +43,8 @@ package main import ( "log" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/ace/v2" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/ace/v3" ) func main() { diff --git a/ace/ace.go b/ace/ace.go index 3771f7dd..c54aedca 100644 --- a/ace/ace.go +++ b/ace/ace.go @@ -10,7 +10,7 @@ import ( "path/filepath" "strings" - core "github.com/gofiber/template" + core "github.com/gofiber/template/v2" "github.com/gofiber/utils" "github.com/yosssi/ace" ) diff --git a/ace/go.mod b/ace/go.mod index c3764a84..a2651e3f 100644 --- a/ace/go.mod +++ b/ace/go.mod @@ -1,11 +1,11 @@ -module github.com/gofiber/template/ace/v2 +module github.com/gofiber/template/ace/v3 -go 1.17 +go 1.25 require github.com/yosssi/ace v0.0.5 require ( - github.com/gofiber/template v1.8.3 + github.com/gofiber/template/v2 v2.0.0 github.com/gofiber/utils v1.1.0 github.com/stretchr/testify v1.11.1 ) @@ -16,4 +16,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/gofiber/template => ../. +replace github.com/gofiber/template/v2 => ../. diff --git a/ace/go.sum b/ace/go.sum index 882cf1bd..1fb2e6fd 100644 --- a/ace/go.sum +++ b/ace/go.sum @@ -1,23 +1,14 @@ -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/yosssi/ace v0.0.5 h1:tUkIP/BLdKqrlrPwcmH0shwEEhTRHoGnc1wFIWmaBUA= github.com/yosssi/ace v0.0.5/go.mod h1:ALfIzm2vT7t5ZE7uoIZqF3TQ7SAOyupFZnkrF5id+K0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/amber/README.md b/amber/README.md index fc2b5791..1a129bab 100644 --- a/amber/README.md +++ b/amber/README.md @@ -43,8 +43,8 @@ package main import ( "log" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/amber/v2" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/amber/v3" ) func main() { diff --git a/amber/amber.go b/amber/amber.go index 220b52d4..dd6d893c 100644 --- a/amber/amber.go +++ b/amber/amber.go @@ -11,7 +11,7 @@ import ( "strings" "github.com/eknkc/amber" - core "github.com/gofiber/template" + core "github.com/gofiber/template/v2" "github.com/gofiber/utils" ) diff --git a/amber/go.mod b/amber/go.mod index 11b43794..f9b42226 100644 --- a/amber/go.mod +++ b/amber/go.mod @@ -1,10 +1,10 @@ -module github.com/gofiber/template/amber/v2 +module github.com/gofiber/template/amber/v3 -go 1.20 +go 1.25 require ( github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 - github.com/gofiber/template v1.8.3 + github.com/gofiber/template/v2 v2.0.0 github.com/gofiber/utils v1.1.0 github.com/stretchr/testify v1.11.1 ) @@ -15,4 +15,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/gofiber/template => ../. +replace github.com/gofiber/template/v2 => ../. diff --git a/django/README.md b/django/README.md index 889e1a68..9f0b4af9 100644 --- a/django/README.md +++ b/django/README.md @@ -49,8 +49,8 @@ package main import ( "log" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/django/v3" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/django/v4" ) func main() { @@ -105,8 +105,8 @@ import ( "embed" "net/http" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/django/v3" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/django/v4" ) //go:embed views diff --git a/django/django.go b/django/django.go index 77125df9..02658a74 100644 --- a/django/django.go +++ b/django/django.go @@ -7,12 +7,11 @@ import ( "net/http" "os" "path/filepath" + "reflect" "strings" - "github.com/gofiber/fiber/v2" - "github.com/flosch/pongo2/v6" - core "github.com/gofiber/template" + core "github.com/gofiber/template/v2" "github.com/gofiber/utils" ) @@ -154,38 +153,52 @@ func (e *Engine) Load() error { // It supports the following types: // - pongo2.Context // - map[string]interface{} -// - fiber.Map -// // It returns nil if the binding is not one of the supported types. func getPongoBinding(binding interface{}) pongo2.Context { if binding == nil { return nil } - var bind pongo2.Context switch binds := binding.(type) { case pongo2.Context: - bind = binds + return sanitizePongoContext(binds) case map[string]interface{}: - bind = binds - case fiber.Map: - bind = make(pongo2.Context) - for key, value := range binds { - // only add valid keys - if isValidKey(key) { - bind[key] = value - } + return sanitizePongoContext(binds) + } + + value := reflect.ValueOf(binding) + if value.Kind() != reflect.Map || value.IsNil() { + return nil + } + + if value.Type().Key().Kind() != reflect.String { + return nil + } + + bind := make(pongo2.Context, value.Len()) + for _, key := range value.MapKeys() { + strKey := key.String() + if !isValidKey(strKey) { + continue } - return bind + bind[strKey] = value.MapIndex(key).Interface() + } + + return bind +} + +func sanitizePongoContext(data map[string]interface{}) pongo2.Context { + if len(data) == 0 { + return make(pongo2.Context) } - // Remove invalid keys - for key := range bind { + bind := make(pongo2.Context, len(data)) + for key, value := range data { if !isValidKey(key) { - delete(bind, key) + continue } + bind[key] = value } - return bind } diff --git a/django/django_test.go b/django/django_test.go index 79c5d019..99070af0 100644 --- a/django/django_test.go +++ b/django/django_test.go @@ -13,11 +13,12 @@ import ( "unicode" "github.com/flosch/pongo2/v6" - "github.com/gofiber/fiber/v2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) +type customMap map[string]interface{} + const ( admin = "admin" ) @@ -116,10 +117,10 @@ func Test_GetPongoBinding(t *testing.T) { result = getPongoBinding(mapBinding) assert.Equal(t, pongo2.Context(mapBinding), result, "Expected the same context") - // Test with fiber.Map - fiberMap := fiber.Map{"key3": "value3"} - result = getPongoBinding(fiberMap) - assert.Equal(t, pongo2.Context(fiberMap), result, "Expected the same context") + // Test with custom map type (fiber.Map compatible) + custom := customMap{"key3": "value3"} + result = getPongoBinding(custom) + assert.Equal(t, pongo2.Context{"key3": "value3"}, result, "Expected the same context") // Test with unsupported type result = getPongoBinding("unsupported") diff --git a/django/go.mod b/django/go.mod index 3530dd58..cd76e6b7 100644 --- a/django/go.mod +++ b/django/go.mod @@ -1,30 +1,18 @@ -module github.com/gofiber/template/django/v3 +module github.com/gofiber/template/django/v4 -go 1.20 +go 1.25 require ( github.com/flosch/pongo2/v6 v6.0.0 - github.com/gofiber/fiber/v2 v2.52.9 - github.com/gofiber/template v1.8.3 + github.com/gofiber/template/v2 v2.0.0 github.com/gofiber/utils v1.1.0 github.com/stretchr/testify v1.11.1 ) require ( - github.com/andybalholm/brotli v1.1.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/klauspost/compress v1.17.9 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.16 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rivo/uniseg v0.2.0 // indirect - github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.51.0 // indirect - github.com/valyala/tcplisten v1.0.0 // indirect - golang.org/x/sys v0.28.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/gofiber/template => ../. +replace github.com/gofiber/template/v2 => ../. diff --git a/django/go.sum b/django/go.sum index e30431ac..9d6f39f1 100644 --- a/django/go.sum +++ b/django/go.sum @@ -1,43 +1,19 @@ -github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= -github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/flosch/pongo2/v6 v6.0.0 h1:lsGru8IAzHgIAw6H2m4PCyleO58I40ow6apih0WprMU= github.com/flosch/pongo2/v6 v6.0.0/go.mod h1:CuDpFm47R0uGGE7z13/tTlt1Y6zdxvr2RLT5LJhsHEU= -github.com/gofiber/fiber/v2 v2.52.9 h1:YjKl5DOiyP3j0mO61u3NTmK7or8GzzWzCFzkboyP5cw= -github.com/gofiber/fiber/v2 v2.52.9/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= -github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1SqA= -github.com/valyala/fasthttp v1.51.0/go.mod h1:oI2XroL+lI7vdXyYoQk03bXBThfFl2cVdIA3Xl7cH8g= -github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= -github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/go.mod b/go.mod index 6a7ace85..3e6d412c 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/gofiber/template +module github.com/gofiber/template/v2 -go 1.20 +go 1.25 diff --git a/handlebars/README.md b/handlebars/README.md index 6cb7ff24..b91fdc40 100644 --- a/handlebars/README.md +++ b/handlebars/README.md @@ -49,8 +49,8 @@ package main import ( "log" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/handlebars/v2" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/handlebars/v3" ) func main() { diff --git a/handlebars/go.mod b/handlebars/go.mod index e4cd7963..a22a2d38 100644 --- a/handlebars/go.mod +++ b/handlebars/go.mod @@ -1,31 +1,20 @@ -module github.com/gofiber/template/handlebars/v2 +module github.com/gofiber/template/handlebars/v3 -go 1.20 +go 1.25 require ( - github.com/gofiber/fiber/v2 v2.52.9 - github.com/gofiber/template v1.8.3 + github.com/gofiber/template/v2 v2.0.0 github.com/gofiber/utils v1.1.0 github.com/mailgun/raymond/v2 v2.0.48 github.com/stretchr/testify v1.11.1 ) require ( - github.com/andybalholm/brotli v1.1.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/klauspost/compress v1.17.9 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.16 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rivo/uniseg v0.2.0 // indirect github.com/sirupsen/logrus v1.8.1 // indirect - github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.51.0 // indirect - github.com/valyala/tcplisten v1.0.0 // indirect golang.org/x/sys v0.28.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/gofiber/template => ../. +replace github.com/gofiber/template/v2 => ../. diff --git a/handlebars/go.sum b/handlebars/go.sum index 61333dbf..4ab7e7fd 100644 --- a/handlebars/go.sum +++ b/handlebars/go.sum @@ -1,29 +1,12 @@ -github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= -github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gofiber/fiber/v2 v2.52.9 h1:YjKl5DOiyP3j0mO61u3NTmK7or8GzzWzCFzkboyP5cw= -github.com/gofiber/fiber/v2 v2.52.9/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/mailgun/raymond/v2 v2.0.48 h1:5dmlB680ZkFG2RN/0lvTAghrSxIESeu9/2aeDqACtjw= github.com/mailgun/raymond/v2 v2.0.48/go.mod h1:lsgvL50kgt1ylcFJYZiULi5fjPBkkhNfj4KA0W54Z18= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= -github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -31,15 +14,7 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1SqA= -github.com/valyala/fasthttp v1.51.0/go.mod h1:oI2XroL+lI7vdXyYoQk03bXBThfFl2cVdIA3Xl7cH8g= -github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= -github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/handlebars/handlebars.go b/handlebars/handlebars.go index fb64f322..1ba69ffd 100644 --- a/handlebars/handlebars.go +++ b/handlebars/handlebars.go @@ -10,9 +10,7 @@ import ( "strings" "sync" - "github.com/gofiber/fiber/v2" - - core "github.com/gofiber/template" + core "github.com/gofiber/template/v2" "github.com/gofiber/utils" "github.com/mailgun/raymond/v2" ) @@ -157,15 +155,7 @@ func (e *Engine) Render(out io.Writer, name string, binding interface{}, layout if lay == nil { return fmt.Errorf("render: LayoutName %s does not exist", layout[0]) } - var bind map[string]interface{} - switch binds := binding.(type) { - case fiber.Map: - bind = binds - case map[string]interface{}: - bind = binds - default: - bind = make(map[string]interface{}, 1) - } + bind := core.AcquireViewContext(binding) bind[e.LayoutName] = raymond.SafeString(parsed) parsed, err := lay.Exec(bind) if err != nil { diff --git a/handlebars/handlebars_test.go b/handlebars/handlebars_test.go index ae830c1f..4832d6a2 100644 --- a/handlebars/handlebars_test.go +++ b/handlebars/handlebars_test.go @@ -9,10 +9,10 @@ import ( "testing" "github.com/stretchr/testify/require" - - "github.com/gofiber/fiber/v2" ) +type customMap map[string]interface{} + func trim(str string) string { trimmed := strings.TrimSpace(regexp.MustCompile(`\s+`).ReplaceAllString(str, " ")) trimmed = strings.ReplaceAll(trimmed, " <", "<") @@ -27,7 +27,7 @@ func Test_Render(t *testing.T) { // Partials var buf bytes.Buffer - err := engine.Render(&buf, "index", fiber.Map{ + err := engine.Render(&buf, "index", customMap{ "Title": "Hello, World!", }) require.NoError(t, err) @@ -38,7 +38,7 @@ func Test_Render(t *testing.T) { // Single buf.Reset() - err = engine.Render(&buf, "errors/404", fiber.Map{ + err = engine.Render(&buf, "errors/404", customMap{ "Title": "Hello, World!", }) require.NoError(t, err) @@ -54,7 +54,7 @@ func Test_Layout(t *testing.T) { require.NoError(t, engine.Load()) var buf bytes.Buffer - err := engine.Render(&buf, "index", fiber.Map{ + err := engine.Render(&buf, "index", customMap{ "Title": "Hello, World!", }, "layouts/main") require.NoError(t, err) @@ -70,7 +70,7 @@ func Test_Empty_Layout(t *testing.T) { require.NoError(t, engine.Load()) var buf bytes.Buffer - err := engine.Render(&buf, "index", fiber.Map{ + err := engine.Render(&buf, "index", customMap{ "Title": "Hello, World!", }, "") require.NoError(t, err) @@ -87,7 +87,7 @@ func Test_FileSystem(t *testing.T) { require.NoError(t, engine.Load()) var buf bytes.Buffer - err := engine.Render(&buf, "index", fiber.Map{ + err := engine.Render(&buf, "index", customMap{ "Title": "Hello, World!", }, "layouts/main") require.NoError(t, err) diff --git a/html/README.md b/html/README.md index 1711fbfe..aa8cd2c5 100644 --- a/html/README.md +++ b/html/README.md @@ -60,8 +60,8 @@ package main import ( "log" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/html/v2" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/html/v3" ) func main() { @@ -113,8 +113,8 @@ import ( "net/http" "embed" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/html/v2" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/html/v3" ) //go:embed views/* @@ -163,8 +163,8 @@ import ( "log" "net/http" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/html/v2" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/html/v3" ) //go:embed views/* diff --git a/html/go.mod b/html/go.mod index 7b72307a..67f02971 100644 --- a/html/go.mod +++ b/html/go.mod @@ -1,9 +1,9 @@ -module github.com/gofiber/template/html/v2 +module github.com/gofiber/template/html/v3 -go 1.20 +go 1.25 require ( - github.com/gofiber/template v1.8.3 + github.com/gofiber/template/v2 v2.0.0 github.com/gofiber/utils v1.1.0 github.com/stretchr/testify v1.11.1 ) @@ -14,4 +14,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/gofiber/template => ../. +replace github.com/gofiber/template/v2 => ../. diff --git a/html/html.go b/html/html.go index 4c1c4c27..18d71908 100644 --- a/html/html.go +++ b/html/html.go @@ -10,7 +10,7 @@ import ( "path/filepath" "strings" - core "github.com/gofiber/template" + core "github.com/gofiber/template/v2" "github.com/gofiber/utils" ) diff --git a/jet/README.md b/jet/README.md index 8a9c85b0..60da32b6 100644 --- a/jet/README.md +++ b/jet/README.md @@ -49,8 +49,8 @@ package main import ( "log" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/jet/v2" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/jet/v3" ) func main() { diff --git a/jet/go.mod b/jet/go.mod index 07035bf4..729a4084 100644 --- a/jet/go.mod +++ b/jet/go.mod @@ -1,31 +1,19 @@ -module github.com/gofiber/template/jet/v2 +module github.com/gofiber/template/jet/v3 -go 1.20 +go 1.25 require ( github.com/CloudyKit/jet/v6 v6.3.1 - github.com/gofiber/fiber/v2 v2.52.9 - github.com/gofiber/template v1.8.3 + github.com/gofiber/template/v2 v2.0.0 github.com/gofiber/utils v1.1.0 github.com/stretchr/testify v1.11.1 ) require ( github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect - github.com/andybalholm/brotli v1.1.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/klauspost/compress v1.17.9 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.16 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rivo/uniseg v0.2.0 // indirect - github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.51.0 // indirect - github.com/valyala/tcplisten v1.0.0 // indirect - golang.org/x/sys v0.28.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/gofiber/template => ../. +replace github.com/gofiber/template/v2 => ../. diff --git a/jet/go.sum b/jet/go.sum index d4384f91..162459f9 100644 --- a/jet/go.sum +++ b/jet/go.sum @@ -2,41 +2,14 @@ github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 h1:sR+/8Yb4s github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= github.com/CloudyKit/jet/v6 v6.3.1 h1:6IAo5Cx21xrHVaR8zzXN5gJatKV/wO7Nf6bfCnCSbUw= github.com/CloudyKit/jet/v6 v6.3.1/go.mod h1:lf8ksdNsxZt7/yH/3n4vJQWA9RUq4wpaHtArHhGVMOw= -github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= -github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gofiber/fiber/v2 v2.52.9 h1:YjKl5DOiyP3j0mO61u3NTmK7or8GzzWzCFzkboyP5cw= -github.com/gofiber/fiber/v2 v2.52.9/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= -github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= -github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1SqA= -github.com/valyala/fasthttp v1.51.0/go.mod h1:oI2XroL+lI7vdXyYoQk03bXBThfFl2cVdIA3Xl7cH8g= -github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= -github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/jet/jet.go b/jet/jet.go index edb35106..4642c384 100644 --- a/jet/jet.go +++ b/jet/jet.go @@ -9,11 +9,9 @@ import ( "path/filepath" "strings" - "github.com/gofiber/fiber/v2" - "github.com/CloudyKit/jet/v6" "github.com/CloudyKit/jet/v6/loaders/httpfs" - core "github.com/gofiber/template" + core "github.com/gofiber/template/v2" "github.com/gofiber/utils" ) @@ -192,23 +190,18 @@ func (e *Engine) Render(out io.Writer, name string, binding interface{}, layout } 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) } return bind } diff --git a/mustache/README.md b/mustache/README.md index a8c7c867..6c61b1cd 100644 --- a/mustache/README.md +++ b/mustache/README.md @@ -49,8 +49,8 @@ package main import ( "log" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/mustache/v2" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/mustache/v3" ) func main() { diff --git a/mustache/go.mod b/mustache/go.mod index 384d6ed1..64a207fc 100644 --- a/mustache/go.mod +++ b/mustache/go.mod @@ -1,30 +1,19 @@ -module github.com/gofiber/template/mustache/v2 +module github.com/gofiber/template/mustache/v3 -go 1.20 +go 1.25 require ( github.com/cbroglie/mustache v1.4.0 - github.com/gofiber/fiber/v2 v2.52.9 - github.com/gofiber/template v1.8.3 + github.com/gofiber/template/v2 v2.0.0 github.com/gofiber/utils v1.1.0 github.com/stretchr/testify v1.11.1 github.com/valyala/bytebufferpool v1.0.0 ) require ( - github.com/andybalholm/brotli v1.1.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/klauspost/compress v1.17.9 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.16 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rivo/uniseg v0.2.0 // indirect - github.com/valyala/fasthttp v1.51.0 // indirect - github.com/valyala/tcplisten v1.0.0 // indirect - golang.org/x/sys v0.28.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/gofiber/template => ../. +replace github.com/gofiber/template/v2 => ../. diff --git a/mustache/go.sum b/mustache/go.sum index 46480cec..be3c93a8 100644 --- a/mustache/go.sum +++ b/mustache/go.sum @@ -1,40 +1,15 @@ -github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= -github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/cbroglie/mustache v1.4.0 h1:Azg0dVhxTml5me+7PsZ7WPrQq1Gkf3WApcHMjMprYoU= github.com/cbroglie/mustache v1.4.0/go.mod h1:SS1FTIghy0sjse4DUVGV1k/40B1qE1XkD9DtDsHo9iM= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gofiber/fiber/v2 v2.52.9 h1:YjKl5DOiyP3j0mO61u3NTmK7or8GzzWzCFzkboyP5cw= -github.com/gofiber/fiber/v2 v2.52.9/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= -github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1SqA= -github.com/valyala/fasthttp v1.51.0/go.mod h1:oI2XroL+lI7vdXyYoQk03bXBThfFl2cVdIA3Xl7cH8g= -github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= -github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/mustache/mustache.go b/mustache/mustache.go index a2c15ff4..9467dc43 100644 --- a/mustache/mustache.go +++ b/mustache/mustache.go @@ -9,10 +9,8 @@ import ( "path/filepath" "strings" - "github.com/gofiber/fiber/v2" - "github.com/cbroglie/mustache" - core "github.com/gofiber/template" + core "github.com/gofiber/template/v2" "github.com/gofiber/utils" "github.com/valyala/bytebufferpool" ) @@ -173,17 +171,7 @@ func (e *Engine) Render(out io.Writer, name string, binding interface{}, layout return err } - var bind map[string]interface{} - - switch binds := binding.(type) { - case fiber.Map: - bind = binds - case map[string]interface{}: - bind = binds - default: - bind = make(map[string]interface{}, 1) - } - + bind := core.AcquireViewContext(binding) bind[e.LayoutName] = buf.String() lay := e.Templates[layout[0]] if lay == nil { diff --git a/mustache/mustache_test.go b/mustache/mustache_test.go index 66056001..be45c2fd 100644 --- a/mustache/mustache_test.go +++ b/mustache/mustache_test.go @@ -9,10 +9,10 @@ import ( "testing" "github.com/stretchr/testify/require" - - "github.com/gofiber/fiber/v2" ) +type customMap map[string]interface{} + func trim(str string) string { trimmed := strings.TrimSpace(regexp.MustCompile(`\s+`).ReplaceAllString(str, " ")) trimmed = strings.ReplaceAll(trimmed, " <", "<") @@ -27,7 +27,7 @@ func Test_Render(t *testing.T) { // Partials var buf bytes.Buffer - err := engine.Render(&buf, "index", fiber.Map{ + err := engine.Render(&buf, "index", customMap{ "Title": "Hello, World!", }) require.NoError(t, err) @@ -38,7 +38,7 @@ func Test_Render(t *testing.T) { // Single buf.Reset() - err = engine.Render(&buf, "errors/404", fiber.Map{ + err = engine.Render(&buf, "errors/404", customMap{ "Title": "Hello, World!", }) require.NoError(t, err) @@ -54,7 +54,7 @@ func Test_Layout(t *testing.T) { require.NoError(t, engine.Load()) var buf bytes.Buffer - err := engine.Render(&buf, "index", fiber.Map{ + err := engine.Render(&buf, "index", customMap{ "Title": "Hello, World!", }, "layouts/main") require.NoError(t, err) @@ -70,7 +70,7 @@ func Test_Empty_Layout(t *testing.T) { require.NoError(t, engine.Load()) var buf bytes.Buffer - err := engine.Render(&buf, "index", fiber.Map{ + err := engine.Render(&buf, "index", customMap{ "Title": "Hello, World!", }, "") require.NoError(t, err) @@ -86,7 +86,7 @@ func Test_FileSystem(t *testing.T) { require.NoError(t, engine.Load()) var buf bytes.Buffer - err := engine.Render(&buf, "index", fiber.Map{ + err := engine.Render(&buf, "index", customMap{ "Title": "Hello, World!", }, "layouts/main") require.NoError(t, err) diff --git a/pug/README.md b/pug/README.md index 8f2c40a6..3b207dc5 100644 --- a/pug/README.md +++ b/pug/README.md @@ -44,8 +44,8 @@ package main import ( "log" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/pug/v2" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/pug/v3" // "net/http" // embedded system ) diff --git a/pug/go.mod b/pug/go.mod index 29eeba84..f3507cef 100644 --- a/pug/go.mod +++ b/pug/go.mod @@ -1,11 +1,11 @@ -module github.com/gofiber/template/pug/v2 +module github.com/gofiber/template/pug/v3 -go 1.20 +go 1.25 require ( github.com/Joker/hpp v1.0.0 github.com/Joker/jade v1.1.3 - github.com/gofiber/template v1.8.3 + github.com/gofiber/template/v2 v2.0.0 github.com/gofiber/utils v1.1.0 github.com/stretchr/testify v1.11.1 ) @@ -17,4 +17,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/gofiber/template => ../. +replace github.com/gofiber/template/v2 => ../. diff --git a/pug/pug.go b/pug/pug.go index d30068fb..8af198f3 100644 --- a/pug/pug.go +++ b/pug/pug.go @@ -12,7 +12,7 @@ import ( "github.com/Joker/hpp" "github.com/Joker/jade" - core "github.com/gofiber/template" + core "github.com/gofiber/template/v2" "github.com/gofiber/utils" ) diff --git a/slim/README.md b/slim/README.md index b4c4ad5f..5d015cc0 100644 --- a/slim/README.md +++ b/slim/README.md @@ -44,8 +44,8 @@ package main import ( "log" - "github.com/gofiber/fiber/v2" - "github.com/gofiber/template/slim/v2" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/template/slim/v3" // "net/http" // embedded system ) diff --git a/slim/go.mod b/slim/go.mod index 544465ee..d39b4094 100644 --- a/slim/go.mod +++ b/slim/go.mod @@ -1,9 +1,9 @@ -module github.com/gofiber/template/slim/v2 +module github.com/gofiber/template/slim/v3 -go 1.20 +go 1.25 require ( - github.com/gofiber/template v1.8.3 + github.com/gofiber/template/v2 v2.0.0 github.com/gofiber/utils v1.1.0 github.com/mattn/go-slim v0.0.4 github.com/stretchr/testify v1.11.1 @@ -16,4 +16,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/gofiber/template => ../. +replace github.com/gofiber/template/v2 => ../. diff --git a/slim/slim.go b/slim/slim.go index e10ab9bc..ce043963 100644 --- a/slim/slim.go +++ b/slim/slim.go @@ -10,7 +10,7 @@ import ( "path/filepath" "strings" - core "github.com/gofiber/template" + core "github.com/gofiber/template/v2" "github.com/gofiber/utils" "github.com/mattn/go-slim" "github.com/valyala/bytebufferpool" diff --git a/template.go b/template.go index ab443f67..86d834f6 100644 --- a/template.go +++ b/template.go @@ -3,6 +3,7 @@ package template import ( "io" "net/http" + "reflect" "sync" ) @@ -127,3 +128,40 @@ func (e *Engine) PreRenderCheck() bool { e.Mutex.Unlock() return false } + +// AcquireViewContext ensures the binding value is represented as a map[string]interface{} +// so template engines can safely inject layout specific data while preserving the +// original values. It supports native map[string]interface{} values as well as +// user-defined map types (for example fiber.Map) with string keys. +func AcquireViewContext(binding interface{}) map[string]interface{} { + if binds, ok := binding.(map[string]interface{}); ok { + return binds + } + + if binding == nil { + return make(map[string]interface{}) + } + + val := reflect.ValueOf(binding) + if val.Kind() == reflect.Pointer { + if val.IsNil() { + return make(map[string]interface{}) + } + val = val.Elem() + } + + if val.Kind() != reflect.Map || val.IsNil() { + return make(map[string]interface{}) + } + + if val.Type().Key().Kind() != reflect.String { + return make(map[string]interface{}) + } + + result := make(map[string]interface{}, val.Len()) + iter := val.MapRange() + for iter.Next() { + result[iter.Key().String()] = iter.Value().Interface() + } + return result +} From 0c90d1d35a62c0cb81ba9682f6f0459a38b14ce4 Mon Sep 17 00:00:00 2001 From: RW Date: Fri, 17 Oct 2025 12:37:28 +0200 Subject: [PATCH 2/7] docs: adapt examples to Fiber v3 ctx interface --- README.md | 4 ++-- ace/README.md | 4 ++-- amber/README.md | 4 ++-- django/README.md | 6 +++--- handlebars/README.md | 4 ++-- html/README.md | 10 +++++----- jet/README.md | 4 ++-- mustache/README.md | 4 ++-- pug/README.md | 4 ++-- slim/README.md | 4 ++-- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index b1ef808b..3abbb80c 100644 --- a/README.md +++ b/README.md @@ -93,14 +93,14 @@ func main() { // To render a template, you can call the ctx.Render function // Render(tmpl string, values interface{}, layout ...string) - app.Get("/", func(c *fiber.Ctx) error { + app.Get("/", func(c fiber.Ctx) error { return c.Render("index", fiber.Map{ "Title": "Hello, World!", }) }) // Render with layout example - app.Get("/layout", func(c *fiber.Ctx) error { + app.Get("/layout", func(c fiber.Ctx) error { return c.Render("index", fiber.Map{ "Title": "Hello, World!", }, "layouts/main") diff --git a/ace/README.md b/ace/README.md index 87dded7b..58d9474f 100644 --- a/ace/README.md +++ b/ace/README.md @@ -60,14 +60,14 @@ func main() { Views: engine, }) - app.Get("/", 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 { + app.Get("/layout", func(c fiber.Ctx) error { // Render index within layouts/main return c.Render("index", fiber.Map{ "Title": "Hello, World!", diff --git a/amber/README.md b/amber/README.md index 1a129bab..b51f0730 100644 --- a/amber/README.md +++ b/amber/README.md @@ -60,14 +60,14 @@ func main() { Views: engine, }) - app.Get("/", 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 { + app.Get("/layout", func(c fiber.Ctx) error { // Render index within layouts/main return c.Render("index", fiber.Map{ "Title": "Hello, World!", diff --git a/django/README.md b/django/README.md index 9f0b4af9..0a7b4b0e 100644 --- a/django/README.md +++ b/django/README.md @@ -66,14 +66,14 @@ func main() { Views: engine, }) - app.Get("/", 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 { + app.Get("/layout", func(c fiber.Ctx) error { // Render index within layouts/main return c.Render("index", fiber.Map{ "Title": "Hello, World!", @@ -121,7 +121,7 @@ func main() { Views: engine, }) - app.Get("/", func(c *fiber.Ctx) error { + app.Get("/", func(c fiber.Ctx) error { // Render descendant return c.Render("descendant", fiber.Map{ "greeting": "World", diff --git a/handlebars/README.md b/handlebars/README.md index b91fdc40..068c5fa9 100644 --- a/handlebars/README.md +++ b/handlebars/README.md @@ -66,14 +66,14 @@ func main() { Views: engine, }) - app.Get("/", 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 { + app.Get("/layout", func(c fiber.Ctx) error { // Render index within layouts/main return c.Render("index", fiber.Map{ "Title": "Hello, World!", diff --git a/html/README.md b/html/README.md index aa8cd2c5..38b60339 100644 --- a/html/README.md +++ b/html/README.md @@ -77,21 +77,21 @@ func main() { Views: engine, }) - app.Get("/", 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 { + 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("/layouts-nested", func(c fiber.Ctx) error { // Render index within layouts/nested/main within layouts/nested/base return c.Render("index", fiber.Map{ "Title": "Hello, World!", @@ -129,7 +129,7 @@ func main() { }) - app.Get("/", func(c *fiber.Ctx) error { + app.Get("/", func(c fiber.Ctx) error { // Render index - start with views directory return c.Render("views/index", fiber.Map{ "Title": "Hello, World!", @@ -182,7 +182,7 @@ func main() { // Pass the engine to the Views app := fiber.New(fiber.Config{Views: engine}) - app.Get("/", func(c *fiber.Ctx) error { + app.Get("/", func(c fiber.Ctx) error { // Render index return c.Render("views/index", fiber.Map{ "Title": "Hello, World!", diff --git a/jet/README.md b/jet/README.md index 60da32b6..b3f2c778 100644 --- a/jet/README.md +++ b/jet/README.md @@ -66,14 +66,14 @@ func main() { Views: engine, }) - app.Get("/", 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 { + app.Get("/layout", func(c fiber.Ctx) error { // Render index within layouts/main return c.Render("index", fiber.Map{ "Title": "Hello, World!", diff --git a/mustache/README.md b/mustache/README.md index 6c61b1cd..6cafbb0f 100644 --- a/mustache/README.md +++ b/mustache/README.md @@ -67,14 +67,14 @@ func main() { Views: engine, }) - app.Get("/", 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 { + app.Get("/layout", func(c fiber.Ctx) error { // Render index within layouts/main return c.Render("index", fiber.Map{ "Title": "Hello, World!", diff --git a/pug/README.md b/pug/README.md index 3b207dc5..ae7997dc 100644 --- a/pug/README.md +++ b/pug/README.md @@ -63,14 +63,14 @@ func main() { Views: engine, }) - app.Get("/", 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 { + app.Get("/layout", func(c fiber.Ctx) error { // Render index within layouts/main return c.Render("index", fiber.Map{ "Title": "Hello, World!", diff --git a/slim/README.md b/slim/README.md index 5d015cc0..e7419d2b 100644 --- a/slim/README.md +++ b/slim/README.md @@ -63,14 +63,14 @@ func main() { Views: engine, }) - app.Get("/", 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 { + app.Get("/layout", func(c fiber.Ctx) error { // Render index within layouts/main return c.Render("index", fiber.Map{ "Title": "Hello, World!", From 83c9935d104623334674e4c04030a0d2471535a0 Mon Sep 17 00:00:00 2001 From: RW Date: Fri, 17 Oct 2025 12:57:05 +0200 Subject: [PATCH 3/7] chore: refresh deps and lint config --- .golangci.yml | 13 ++++++------- handlebars/go.mod | 4 ++-- handlebars/go.sum | 8 +++++--- pug/go.mod | 2 +- pug/go.sum | 4 ++-- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index a5b91d75..fd91b02b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,11 +1,10 @@ # Created based on v1.56.1 # NOTE: Keep this in sync with the version in .github/workflows/linter.yml +version: 2 + run: modules-download-mode: readonly - skip-dirs-use-default: false - skip-dirs: - - internal output: sort-results: true @@ -60,7 +59,6 @@ linters-settings: desc: '`io/ioutil` package is deprecated, use the `io` and `os` package instead' govet: - check-shadowing: true enable-all: true disable: - shadow @@ -159,6 +157,9 @@ linters-settings: issues: exclude-use-default: false + exclude-dirs-use-default: false + exclude-dirs: + - internal linters: disable: @@ -177,9 +178,8 @@ linters: - errchkjson - errname - errorlint - - execinquery - exhaustive - - exportloopref + - copyloopvar - forbidigo - forcetypeassert - gochecksumtype @@ -221,7 +221,6 @@ linters: - testpackage - thelper - tparallel - - typecheck - unconvert - unparam - unused diff --git a/handlebars/go.mod b/handlebars/go.mod index a22a2d38..9411922a 100644 --- a/handlebars/go.mod +++ b/handlebars/go.mod @@ -12,8 +12,8 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/sirupsen/logrus v1.8.1 // indirect - golang.org/x/sys v0.28.0 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + golang.org/x/sys v0.37.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/handlebars/go.sum b/handlebars/go.sum index 4ab7e7fd..076f4f68 100644 --- a/handlebars/go.sum +++ b/handlebars/go.sum @@ -7,16 +7,18 @@ github.com/mailgun/raymond/v2 v2.0.48 h1:5dmlB680ZkFG2RN/0lvTAghrSxIESeu9/2aeDqA github.com/mailgun/raymond/v2 v2.0.48/go.mod h1:lsgvL50kgt1ylcFJYZiULi5fjPBkkhNfj4KA0W54Z18= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ= +golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/pug/go.mod b/pug/go.mod index f3507cef..93f4bb1f 100644 --- a/pug/go.mod +++ b/pug/go.mod @@ -13,7 +13,7 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.46.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/pug/go.sum b/pug/go.sum index af7a5dba..694177c4 100644 --- a/pug/go.sum +++ b/pug/go.sum @@ -19,8 +19,8 @@ golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4= +golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= From 9e9a3d7ad4a3c421fcd0f59de14b89292ec89004 Mon Sep 17 00:00:00 2001 From: RW Date: Fri, 17 Oct 2025 13:29:08 +0200 Subject: [PATCH 4/7] chore: adopt golangci-lint v2 --- .github/workflows/golangci-lint.yml | 4 +++- .golangci.yml | 35 ++++++++++------------------- template.go | 5 +++-- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 34502039..7ef2ee48 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -38,6 +38,8 @@ jobs: cache: false - name: golangci-lint uses: golangci/golangci-lint-action@v6 + env: + GOLANGCI_LINT_SKIP_GOVERSION_CHECK: "1" with: # NOTE: Keep this in sync with the version from .golangci.yml - version: 'v1.56.2' + version: 'v2.5.0' diff --git a/.golangci.yml b/.golangci.yml index fd91b02b..5494360d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,5 @@ -# Created based on v1.56.1 -# NOTE: Keep this in sync with the version in .github/workflows/linter.yml +# Created for golangci-lint v2.5.0 +# NOTE: Keep this in sync with the version in .github/workflows/golangci-lint.yml version: 2 @@ -38,10 +38,6 @@ linters-settings: disabled-checks: - ifElseChain - gofumpt: - module-path: github.com/gofiber/template - extra-rules: true - gosec: excludes: - G104 # Provided by errcheck @@ -131,22 +127,11 @@ linters-settings: - name: use-any # TODO Enable for v3 release disabled: true - stylecheck: - checks: - - all - - -ST1000 - - -ST1020 - - -ST1021 - - -ST1022 - tagliatelle: case: rules: json: snake - tenv: - all: true - #unparam: # check-exported: true @@ -155,6 +140,15 @@ linters-settings: - github.com/gofiber/fiber/* - github.com/valyala/fasthttp +formatters: + enable: + - gofumpt + - goimports + settings: + gofumpt: + module-path: github.com/gofiber/template + extra-rules: true + issues: exclude-use-default: false exclude-dirs-use-default: false @@ -185,13 +179,9 @@ linters: - gochecksumtype - goconst - gocritic - - gofmt - - gofumpt - - goimports - gomoddirectives - goprintffuncname - gosec - - gosimple - gosmopolitan - govet - grouper @@ -214,7 +204,6 @@ linters: - rowserrcheck - sqlclosecheck - staticcheck - - stylecheck - tagalign - tagliatelle - testifylint @@ -227,5 +216,5 @@ linters: - usestdlibvars - wastedassign - whitespace + - unqueryvet - wrapcheck - - tenv diff --git a/template.go b/template.go index 86d834f6..feb86917 100644 --- a/template.go +++ b/template.go @@ -1,3 +1,4 @@ +// Package template provides shared rendering primitives for Fiber template engines. package template import ( @@ -113,8 +114,8 @@ func (e *Engine) Reload(enabled bool) IEngineCore { return e } -// Check if the engine should reload the templates before rendering -// Explicit Mute Unlock vs defer offers better performance +// PreRenderCheck determines if the engine should reload the templates before rendering. +// Explicit mutex unlock vs defer offers better performance. func (e *Engine) PreRenderCheck() bool { e.Mutex.Lock() From 86c106b444a47828b4b014af2200a3ce3723138b Mon Sep 17 00:00:00 2001 From: RW Date: Fri, 17 Oct 2025 15:12:08 +0200 Subject: [PATCH 5/7] chore: update lint action for v2 --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 7ef2ee48..63c77071 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -37,7 +37,7 @@ jobs: go-version: '1.25.x' cache: false - name: golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v7 env: GOLANGCI_LINT_SKIP_GOVERSION_CHECK: "1" with: From ea018a7ecedee4ea003c481a3b0bd867850bc851 Mon Sep 17 00:00:00 2001 From: RW Date: Fri, 17 Oct 2025 15:45:32 +0200 Subject: [PATCH 6/7] chore: adapt golangci config to v2 schema --- .golangci.yml | 269 ++++++++++++++++++++++---------------------------- 1 file changed, 118 insertions(+), 151 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 5494360d..2acbf7af 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,160 +1,11 @@ # Created for golangci-lint v2.5.0 # NOTE: Keep this in sync with the version in .github/workflows/golangci-lint.yml -version: 2 +version: "2" run: modules-download-mode: readonly -output: - sort-results: true - -linters-settings: - errcheck: - check-type-assertions: true - check-blank: true - disable-default-exclusions: true - exclude-functions: - - '(*bytes.Buffer).Write' # always returns nil error - - '(*github.com/valyala/bytebufferpool.ByteBuffer).Write' # always returns nil error - - '(*github.com/valyala/bytebufferpool.ByteBuffer).WriteByte' # always returns nil error - - '(*github.com/valyala/bytebufferpool.ByteBuffer).WriteString' # always returns nil error - - errchkjson: - report-no-exported: true - - exhaustive: - default-signifies-exhaustive: true - - forbidigo: - forbid: - - ^(fmt\.Print(|f|ln)|print|println)$ - - 'http\.Default(Client|Transport)' - # TODO: Eventually enable these patterns - # - 'time\.Sleep' - # - 'panic' - - gocritic: - disabled-checks: - - ifElseChain - - gosec: - excludes: - - G104 # Provided by errcheck - config: - global: - audit: true - - depguard: - rules: - main: - deny: - - pkg: flag - desc: '`flag` package is only allowed in main.go' - - pkg: io/ioutil - desc: '`io/ioutil` package is deprecated, use the `io` and `os` package instead' - - govet: - enable-all: true - disable: - - shadow - - fieldalignment - - loopclosure - - grouper: - import-require-single-import: true - import-require-grouping: true - - misspell: - locale: US - - nolintlint: - require-explanation: true - require-specific: true - - nonamedreturns: - report-error-in-defer: true - - predeclared: - q: true - - promlinter: - strict: true - - revive: - enable-all-rules: true - rules: - # Provided by gomnd linter - - name: add-constant - disabled: true - - name: argument-limit - disabled: true - # Provided by bidichk - - name: banned-characters - disabled: true - - name: cognitive-complexity - disabled: true - - name: comment-spacings - disabled: true # TODO https://github.com/gofiber/fiber/issues/2816 - - name: cyclomatic - disabled: true - - name: early-return - severity: warning - disabled: true - - name: exported - disabled: true - - name: file-header - disabled: true - - name: function-result-limit - disabled: true - - name: function-length - disabled: true - - name: line-length-limit - disabled: true - - name: max-public-structs - disabled: true - - name: modifies-parameter - disabled: true - - name: nested-structs - disabled: true - - name: package-comments - disabled: true - - name: unchecked-type-assertion - disabled: true # TODO https://github.com/gofiber/fiber/issues/2816 - # Provided by errcheck - - name: unhandled-error - disabled: true - - name: use-any # TODO Enable for v3 release - disabled: true - - tagliatelle: - case: - rules: - json: snake - - #unparam: - # check-exported: true - - wrapcheck: - ignorePackageGlobs: - - github.com/gofiber/fiber/* - - github.com/valyala/fasthttp - -formatters: - enable: - - gofumpt - - goimports - settings: - gofumpt: - module-path: github.com/gofiber/template - extra-rules: true - -issues: - exclude-use-default: false - exclude-dirs-use-default: false - exclude-dirs: - - internal - linters: disable: - spancheck @@ -199,7 +50,6 @@ linters: - perfsprint - predeclared - promlinter - - reassign - revive - rowserrcheck - sqlclosecheck @@ -218,3 +68,120 @@ linters: - whitespace - unqueryvet - wrapcheck + settings: + errcheck: + check-type-assertions: true + check-blank: true + disable-default-exclusions: true + exclude-functions: + - '(*bytes.Buffer).Write' + - '(*github.com/valyala/bytebufferpool.ByteBuffer).Write' + - '(*github.com/valyala/bytebufferpool.ByteBuffer).WriteByte' + - '(*github.com/valyala/bytebufferpool.ByteBuffer).WriteString' + errchkjson: + report-no-exported: true + exhaustive: + default-signifies-exhaustive: true + forbidigo: + forbid: + - pattern: ^(fmt\.Print(|f|ln)|print|println)$ + - pattern: 'http\.Default(Client|Transport)' + gocritic: + disabled-checks: + - ifElseChain + gosec: + excludes: + - G104 + config: + global: + audit: true + depguard: + rules: + main: + deny: + - pkg: flag + desc: '`flag` package is only allowed in main.go' + - pkg: io/ioutil + desc: '`io/ioutil` package is deprecated, use the `io` and `os` package instead' + govet: + enable-all: true + disable: + - shadow + - fieldalignment + - loopclosure + grouper: + import-require-single-import: true + import-require-grouping: true + misspell: + locale: US + nolintlint: + require-explanation: true + require-specific: true + nonamedreturns: + report-error-in-defer: true + predeclared: + qualified-name: true + promlinter: + strict: true + revive: + enable-all-rules: true + rules: + - name: add-constant + disabled: true + - name: argument-limit + disabled: true + - name: banned-characters + disabled: true + - name: cognitive-complexity + disabled: true + - name: comment-spacings + disabled: true # TODO https://github.com/gofiber/fiber/issues/2816 + - name: cyclomatic + disabled: true + - name: early-return + severity: warning + disabled: true + - name: exported + disabled: true + - name: file-header + disabled: true + - name: function-result-limit + disabled: true + - name: function-length + disabled: true + - name: line-length-limit + disabled: true + - name: max-public-structs + disabled: true + - name: modifies-parameter + disabled: true + - name: nested-structs + disabled: true + - name: package-comments + disabled: true + - name: unchecked-type-assertion + disabled: true # TODO https://github.com/gofiber/fiber/issues/2816 + - name: unhandled-error + disabled: true + - name: use-any + disabled: true + tagliatelle: + case: + rules: + json: snake + wrapcheck: + ignore-package-globs: + - github.com/gofiber/fiber/* + - github.com/valyala/fasthttp + exclusions: + paths: + - internal + +formatters: + enable: + - gofumpt + - goimports + settings: + gofumpt: + module-path: github.com/gofiber/template + extra-rules: true From 05b6534de6d13f35371ef2a6a5f5b094c68fc51b Mon Sep 17 00:00:00 2001 From: RW Date: Thu, 30 Oct 2025 13:07:45 +0100 Subject: [PATCH 7/7] docs: unify readme go version guidance --- README.md | 2 +- ace/README.md | 10 +++++++++- amber/README.md | 10 +++++++++- django/README.md | 10 +++++++++- handlebars/README.md | 10 +++++++++- html/README.md | 10 +++++++++- jet/README.md | 10 +++++++++- mustache/README.md | 10 +++++++++- pug/README.md | 10 +++++++++- slim/README.md | 10 +++++++++- 10 files changed, 82 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3abbb80c..462c2536 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ This package provides universal methods to use multiple template engines with th - [slim](./slim/README.md) ### Installation -> Go version `1.25` or higher is required. +Go version support: We only support the latest two versions of Go. Visit https://go.dev/doc/devel/release for more information. ``` go get -u github.com/gofiber/fiber/v3 diff --git a/ace/README.md b/ace/README.md index 58d9474f..9c0d07c8 100644 --- a/ace/README.md +++ b/ace/README.md @@ -9,7 +9,15 @@ title: Ace Ace is a template engine create by [yossi](https://github.com/yosssi/ace), to see the original syntax documentation please [click here](https://github.com/yosssi/ace/blob/master/documentation/syntax.md) -### Basic Example +## Installation + +Go version support: We only support the latest two versions of Go. Visit https://go.dev/doc/devel/release for more information. + +``` +go get github.com/gofiber/template/ace/v3 +``` + +## Basic Example _**./views/index.ace**_ ```html diff --git a/amber/README.md b/amber/README.md index b51f0730..8eb0c246 100644 --- a/amber/README.md +++ b/amber/README.md @@ -9,7 +9,15 @@ title: Amber Amber is a template engine create by [eknkc](https://github.com/eknkc/amber), to see the original syntax documentation please [click here](https://github.com/eknkc/amber#tags) -### Basic Example +## Installation + +Go version support: We only support the latest two versions of Go. Visit https://go.dev/doc/devel/release for more information. + +``` +go get github.com/gofiber/template/amber/v3 +``` + +## Basic Example _**./views/index.amber**_ ```html diff --git a/django/README.md b/django/README.md index 0a7b4b0e..476fa699 100644 --- a/django/README.md +++ b/django/README.md @@ -9,7 +9,15 @@ title: Django Django is a template engine create by [flosch](https://github.com/flosch/pongo2), to see the original syntax documentation please [click here](https://docs.djangoproject.com/en/dev/topics/templates/) -### Basic Example +## Installation + +Go version support: We only support the latest two versions of Go. Visit https://go.dev/doc/devel/release for more information. + +``` +go get github.com/gofiber/template/django/v4 +``` + +## Basic Example _**./views/index.django**_ ```html diff --git a/handlebars/README.md b/handlebars/README.md index 068c5fa9..f01418d3 100644 --- a/handlebars/README.md +++ b/handlebars/README.md @@ -9,7 +9,15 @@ title: Handlebars Handlebars is a template engine create by [aymerick](https://github.com/aymerick/raymond), to see the original syntax documentation please [click here](https://github.com/aymerick/raymond#table-of-contents) -### Basic Example +## Installation + +Go version support: We only support the latest two versions of Go. Visit https://go.dev/doc/devel/release for more information. + +``` +go get github.com/gofiber/template/handlebars/v3 +``` + +## Basic Example _**./views/index.hbs**_ ```html diff --git a/html/README.md b/html/README.md index 38b60339..bdd6044e 100644 --- a/html/README.md +++ b/html/README.md @@ -9,13 +9,21 @@ title: HTML HTML is the official Go template engine [html/template](https://golang.org/pkg/html/template/), to see the original syntax documentation please [click here](TEMPLATES_CHEATSHEET.md) +## Installation + +Go version support: We only support the latest two versions of Go. Visit https://go.dev/doc/devel/release for more information. + +``` +go get github.com/gofiber/template/html/v3 +``` + **Info:** All templates within the specified view directory are analyzed and compiled at the beginning to increase the performance when using them. Thus it should be noted that no `definition` with the same name should exist, otherwise they will overwrite each other. For templating the `{{embed}}` tag should be used -### Basic Example +## Basic Example _**./views/index.html**_ diff --git a/jet/README.md b/jet/README.md index b3f2c778..72f10597 100644 --- a/jet/README.md +++ b/jet/README.md @@ -9,7 +9,15 @@ title: Jet Jet is a template engine create by [cloudykit](https://github.com/CloudyKit/jet), to see the original syntax documentation please [click here](https://github.com/CloudyKit/jet/wiki/3.-Jet-template-syntax) -### Basic Example +## Installation + +Go version support: We only support the latest two versions of Go. Visit https://go.dev/doc/devel/release for more information. + +``` +go get github.com/gofiber/template/jet/v4 +``` + +## Basic Example _**./views/index.jet**_ ```html diff --git a/mustache/README.md b/mustache/README.md index 6cafbb0f..3aeea553 100644 --- a/mustache/README.md +++ b/mustache/README.md @@ -9,7 +9,15 @@ title: Mustache Mustache is a template engine created by [hoisie/cbroglie](https://github.com/cbroglie/mustache), to see the original syntax documentation please [click here](https://mustache.github.io/mustache.5.html) -### Basic Example +## Installation + +Go version support: We only support the latest two versions of Go. Visit https://go.dev/doc/devel/release for more information. + +``` +go get github.com/gofiber/template/mustache/v4 +``` + +## Basic Example _**./views/index.mustache**_ ```html diff --git a/pug/README.md b/pug/README.md index ae7997dc..d4340906 100644 --- a/pug/README.md +++ b/pug/README.md @@ -9,7 +9,15 @@ title: Pug Pug is a template engine create by [joker](https://github.com/Joker/jade), to see the original syntax documentation please [click here](https://pugjs.org/language/tags.html) -### Basic Example +## Installation + +Go version support: We only support the latest two versions of Go. Visit https://go.dev/doc/devel/release for more information. + +``` +go get github.com/gofiber/template/pug/v3 +``` + +## Basic Example _**./views/index.pug**_ ```html diff --git a/slim/README.md b/slim/README.md index e7419d2b..eb2e0350 100644 --- a/slim/README.md +++ b/slim/README.md @@ -9,7 +9,15 @@ title: Slim Slim is a template engine created by [mattn](https://github.com/mattn/go-slim), to see the original syntax documentation please [click here](https://rubydoc.info/gems/slim/frames) -### Basic Example +## Installation + +Go version support: We only support the latest two versions of Go. Visit https://go.dev/doc/devel/release for more information. + +``` +go get github.com/gofiber/template/slim/v3 +``` + +## Basic Example _**./views/index.slim**_ ```html