Fiber: 馃 render: template login.jet.html does not exist

Created on 21 Jul 2020  路  4Comments  路  Source: gofiber/fiber

render: template login.jet.html does not exist
I am trying to render a view using the jet template engine and somehow it can not be found. It used to work before the update though
Is there something that I'm doing wrong?
Code snippet

app := fiber.New()

    //let app know what template engine we use for the views and shit
    // engine := jet.New("./views", ".jet")
    // app.Settings.Views = engine

    //all images to be accessed in views
    app.Static("/images", "./public/images")

    engine := jet.New("./views/", ".jet")
    app.Settings.Views = engine

func GetLogin(c *fiber.Ctx) {
    err := c.Render("login.jet.html", nil)
    if err != nil {
        logrus.Warn(err)
        c.Send(err)
    }

}
馃 Question

All 4 comments

Thanks for opening your first issue here! 馃帀 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

Hi @petersephrin,
Small question, did you import github.com/gofiber/template/jet? You might want to follow the example as shown here.
Let me know if you have the right imports and are running our latest and compatible versions by running go get -u in your project's directory.

I did. I made the following changes and it works now

    engine := jet.New("./views", ".jet")
func GetLogin(c *fiber.Ctx) {
    err := c.Render("login", nil)
    if err != nil {
        logrus.Warn(err)
        c.Send(err)
    }

}

I also renamed my views to login.jet instead of login.jet.html

I'm happy it's resolved. Make sure you pass the correct template extension on engine initialization 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

renanbastos93 picture renanbastos93  路  3Comments

MohamedGouaouri picture MohamedGouaouri  路  3Comments

renatojf picture renatojf  路  3Comments

ahan picture ahan  路  3Comments

abowloflrf picture abowloflrf  路  4Comments