template icon indicating copy to clipboard operation
template copied to clipboard

🤗 [Question]: Is it possible to use django/v3 on gofiber/v3.0.0-beta?

Open var-rain opened this issue 1 year ago • 9 comments

Question Description

I've tried using django/v3 on gofiber/v3 but can't get past '{{ xxx }}' to get the arguments. is there a problem with my code?

Code Snippet (optional)

package main

import (
	// "github.com/gofiber/fiber/v2" // he worked very well.
	"github.com/gofiber/fiber/v3"
	"github.com/gofiber/template/django/v3"
)

func main() {
	engine := django.New("views", ".html")
	engine.SetAutoEscape(false)
	app := fiber.New(fiber.Config{
		Views: engine,
	})
        // app.Get("/", func(ctx *fiber.Ctx) error { // gofiber/v2
	app.Get("/", func(ctx fiber.Ctx) error {
		return ctx.Render("index", fiber.Map{
			"Title":   "test title",
			"Content": "test content",
		})
	})
	app.Listen(":7200")
}

// views/index.html
// 
// <!DOCTYPE html>
// <html lang="en">
// <head>
//    <title>{{ Title }}</title>
// </head>
// 
// <body>
// <div>
//     {{ Content }}
// </div>
// </body>
// </html>

Checklist:

  • [X] I agree to follow Fiber's Code of Conduct.
  • [X] I have checked for existing issues that describe my questions prior to opening this one.
  • [X] I understand that improperly formatted questions may be closed without explanation.

var-rain avatar Feb 01 '24 21:02 var-rain

@var-rain confirm this works with v2 but not main/v3?

sixcolors avatar Feb 01 '24 22:02 sixcolors

@var-rain The middlewares haven't been migrated/Tested with Fiber V3

gaby avatar Feb 02 '24 00:02 gaby

@var-rain That's the version for the django template. It's in the todo list to migrate these to GoFiber v3

gaby avatar Feb 02 '24 00:02 gaby

Lets re-open this then

gaby avatar Feb 02 '24 00:02 gaby