golive
golive copied to clipboard
How to use with a template engine
Thanks so much for this project! I'm finding it really fun to work with.
I'm new to gofiber and I was wondering how would I use golive with gofiber and a template engine instead of returning static HTML like in your examples in the TemplateHandler
function. I tried using a template engine but it looks like none of the data or interaction is correctly working in an interactive way.
Something like
app.Get("/", func(c *fiber.Ctx) error {
// Render index template
return c.Render("view", fiber.Map{
"Title": "Hello, World!",
})
})
I do see one mistake I have here which is there's no creation of the model object, but I'm not really sure how this flows with golive so I'm a little confused. I would really appreciate the help! Thanks so much for putting your time into this project I tried a bunch of similar ones and this one has been by far the funnest one to work with.
Just so I understand, would you like to create a live view per route?
If yes, it is possible to use the library handler itself
app.Get("/", liveServer.CreateHTMLHandler(components.NewClock, golive.PageContent{
Lang: "us",
Title: "Hello world",
}))
Yes perfect thank you! That worked great. Is this the best place to discuss your library if we have any questions on how to use it?