Skip to content
This repository has been archived by the owner on Aug 28, 2022. It is now read-only.

How to use with a template engine #38

Open
kellabyte opened this issue Aug 19, 2022 · 2 comments
Open

How to use with a template engine #38

kellabyte opened this issue Aug 19, 2022 · 2 comments

Comments

@kellabyte
Copy link

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.

@brendonmatos
Copy link
Owner

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",
	}))

@kellabyte
Copy link
Author

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants