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've tried following code to link template and CSS/JS/IMAGES inside public folder usin go rice.
router := gin.Default()
box := rice.MustFindBox("public")
cssFileServer := http.StripPrefix("/", http.FileServer(box.HTTPBox()))
http.Handle("/pbc", cssFileServer)
//new template engine
basic := gorice.NewWithConfig(rice.MustFindBox("templates"), goview.Config{
Root: "templates",
Extension: ".html",
Master: "layouts/master",
Partials: []string{"partials/ad"},
Funcs: template.FuncMap{
"copy": func() string {
return time.Now().Format("2006")
},
},
DisableCache: true,
})
router.HTMLRender = ginview.Wrap(basic)
router.GET("/", func(ctx *gin.Context) {
// `HTML()` is a helper func to deal with multiple TemplateEngine's.
// It detects the suitable TemplateEngine for each path automatically.
ginview.HTML(ctx, http.StatusOK, "index", gin.H{
"title": "Frontend title!",
})
})
http.ListenAndServe(":8080", router)
I tried to run above query but unable to link CSS file in template
What will be the link for CSS that would be used in template file?
Will it be
/public/assets/app.css OR
/pbc/assets/app.css OR
/assets/app.css
The text was updated successfully, but these errors were encountered:
My folder structure is:
I've tried following code to link template and CSS/JS/IMAGES inside public folder usin go rice.
I tried to run above query but unable to link CSS file in template
What will be the link for CSS that would be used in template file?
Will it be
/public/assets/app.css OR
/pbc/assets/app.css OR
/assets/app.css
The text was updated successfully, but these errors were encountered: