gofiber / template

šŸ§¬ Template engine middleware for Fiber
https://docs.gofiber.io/guide/templates
MIT License
260 stars 52 forks source link

šŸ¤— [Question]: Is it possible to use django/v3 on gofiber/v3.0.0-beta? #333

Open var-rain opened 7 months ago

var-rain commented 7 months ago

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:

var-rain commented 7 months ago

I've used the gofiber/v3 for production

sixcolors commented 7 months ago

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

var-rain commented 7 months ago

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

Yes, the same code I tried several times between v2 and v3, when using {{ Content }} to get data in v2 it works fine, but in v3 you get a blank page

var-rain commented 7 months ago

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

look this ā†“ā†“ā†“ā†“ā†“ simple_test_v3 simple_test_v2

gaby commented 7 months ago

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

var-rain commented 7 months ago

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

Ok, thanks, I thought django/v3 was the counterpart to gofiber/v3.

gaby commented 7 months ago

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

var-rain commented 7 months ago

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

I've tried html (html/template) before this and it works on v3, so...

gaby commented 7 months ago

Lets re-open this then