Open lennard-brinkhaus opened 2 years ago
Thinking about how to design this. I foresee some non-string examples for this.
Let's say a PDF / Word document renderer wouldn't be happy with a string input so Render(tpl string)
is not viable. I'm thinking either []byte or interface{} but I'd prefer not having interface parameters.
Would there be a situation that is not covered by []byte? Raw file contents and strings both work with that. @0SkillAllLuck
My current proposal would be Render(tpl []byte) error
and the respective MustRender(tpl []byte)
resulting in the proposed code snippet changing to:
package main
import "github.com/go-mojito/mojito"
func main() {
mojito.GET("/", func(ctx mojito.RendererContext) {
ctx.MustRender([]byte(`
<html>
<body>
<h1>Hello World</h1>
</body>
</html>
`))
})
mojito.ListenAndServe(":8123")
}
I agree, an alternative would be to have a seperate ctx.RenderString(tpl string)
function but that would be the worse option I think. So going with your suggestion @nilathedragon looks like the better way to me.
Description
It would be great, to have the possibility to render / show a custom HTML string and not only a path to a specific file.
Additional Context
No response
Code Snippet
Checklist: