GeertJohan/go.rice

How to link CSS with template in box

sujit-baniya opened this issue · 0 comments

My folder structure is:

/template
    /layouts
        master.html
    page.html
/public
    /assets
        app.css

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