Fiber: 馃敟 template engines

Created on 12 Feb 2020  路  7Comments  路  Source: gofiber/fiber

Is your feature request related to a problem?
No

Describe the solution you'd like
Template engines like in express
https://expressjs.com/en/guide/using-template-engines.html

Describe alternatives you've considered
No ideia

Additional context
Not only static files but also template engine to also support pass data to template and render it

Most helpful comment

We only support Go engines for now, maybe we write our own in the far future.

All 7 comments

Thanks for opening your first issue here! 馃帀 Be sure to follow the issue template!

@mauricionr, we just released v1.6.0

Template rendering now our no.1 priority :+1:, I will keep this issue open until we got more updates.

Render is available on the master branch for testing, 6 template engines are available:

The function uses the correct engine based on the file extension.

func main() {
  app := fiber.New()
  app.Get("/", func(c *fiber.Ctx) {
    data := map[string]interface{}{
      "name": "John",
      "age":  "35",
    }
    var err error
    //err = c.Render("views/test.template", data)
    //err = c.Render("views/test.ace", data)
    //err = c.Render("views/test.amber", data)
    //err = c.Render("views/test.jet", data)
    //err = c.Render("views/test.raymond", data)
    err = c.Render("views/test.mustache", data)
    if err != nil {
      fmt.Println(err)
    }
  })

  app.Listen(3000)
}

json could be added as a template? like in phoenix :see_no_evil: :thinking:

@mauricionr, feel free to suggest go template engines ( a link would be nice :smile: )

https://hexdocs.pm/phoenix/views.html#rendering-json

sorry i forgot to put the link

We only support Go engines for now, maybe we write our own in the far future.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MohamedGouaouri picture MohamedGouaouri  路  3Comments

faultable picture faultable  路  3Comments

ahan picture ahan  路  3Comments

Aguezz picture Aguezz  路  4Comments

Terisback picture Terisback  路  3Comments