You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am totally new with go, but I am trying to prepare simple web page and I want to embed tempaltes files to final binary.
My question is how to do that ;-)
I've prepared someting like:
//go:embed templates
var assets embed.FS
// and passes it to my application config:
app.TemplatesFS = assets
but I have no idea how to use it with jet templates.
I am using jet with files on file system:
var view = jet.NewSet(
jet.NewOSFileSystemLoader("./templates"),
jet.InDevelopmentMode(), // remove in production
)
then I have function to render:
func TemplateRender(w http.ResponseWriter, tplName string, data jet.VarMap) error {
t, err := view.GetTemplate(tplName)
if err != nil {
log.Printf("Template not found or other error ocurred: %v", err)
return err
}
err = t.Execute(w, data, nil)
if err != nil {
log.Printf("Error execution template: %v", err)
return err
}
return nil
}
and this is working fine, but when I move compiled app to some other place I do not have access to my html files :(
Can someone show me (in a very simple code ;-) :-) ) how to do that - this would be some start for me
thanks!
The text was updated successfully, but these errors were encountered:
This is a bit of an open issue, basically you have to write an adapter between Go's fs.FS and jet's Loader interface. See #191 for more details. A workaround is to just use http.FS, which Jet already knows how to use.
I'll close this because it's basically the same feature request as #191, but feel free to reply here or reopen when the information in #191 doesn't completely solve your problem.
Thanks for replay ;-) I have seen this issue but, as I mentioned I am starting learning go, I do not know how to pass this loader to Jet Engine ;-) But I will try to experiment with it - maybe I will find the way ;-)
Hi,
I am totally new with go, but I am trying to prepare simple web page and I want to embed tempaltes files to final binary.
My question is how to do that ;-)
I've prepared someting like:
but I have no idea how to use it with jet templates.
I am using jet with files on file system:
then I have function to render:
and this is working fine, but when I move compiled app to some other place I do not have access to my html files :(
Can someone show me (in a very simple code ;-) :-) ) how to do that - this would be some start for me
thanks!
The text was updated successfully, but these errors were encountered: