Skip to main content

All Questions

Tagged with
1 vote
0 answers
12 views

HTMLGlob template pattern matching with nested subdirectories

I am working on a golang project using gin and go templating. My templates are in a structure like so: C:. ├───components ├───display .... I would like to add subdirectories to organise the templates,...
ancient geek's user avatar
4 votes
1 answer
598 views

gin gonic nested templates

Go base lib's template has method Execute which allows to reference another template in order to use template nesting, like follows: template.Template.Execute("base", data) Also see this SO ...
Piotr Zakrzewski's user avatar
0 votes
0 answers
189 views

Make a clickable div in Golang Template

I would like to make a table where you can click on the rows using bulma and gin/gonic with golang. ---- I am familiar with Angular and other js frameworks that enable the ease of adding (click) event ...
Jon Atollah's user avatar
1 vote
1 answer
436 views

gin HTMLGlob not applying **

I have a gin v1.8.1 go program that uses templates. Main go file is cmd/app/app.go. Inside it, I have this r := gin.Default() cwd, err := os.Getwd() if err != nil { panic(err) ...
Paul Waldo's user avatar
  • 1,203
0 votes
1 answer
2k views

Golang Gin Middleware pass Data to Template

Hi currently i am doing a little project and i have question. Is there a way to pass Data to a template from a Middleware? For Example: func CheckAuth(c *gin.Context) { //This Middleware gets the user ...
Z01Natsu's user avatar
0 votes
0 answers
368 views

gin-gonic templates only ever showing one form

I have been setting up my gin templates to use a base template that sets out the layout for my various views. The problem I am having is that all views show my Register page, no matter what route I ...
3therk1ll's user avatar
  • 2,298
1 vote
1 answer
2k views

In golang gin simple template example, how do you render a string without quotes?

Using example golang gin code from README: func main() { router := gin.Default() router.LoadHTMLGlob("templates/*") router.GET("/", func(c *gin.Context) { c.HTML(http.StatusOK, "index....
Andrew Arrow's user avatar
  • 4,414
0 votes
1 answer
1k views

How to show variable in Golang template inside range

I have some code on the server: c.HTML(http.StatusOK, "videos.html", gin.H{ "files": files, //slice "errMessage": errMessage, }) And I have some code on the ...
Rattrap's user avatar
  • 315
0 votes
1 answer
101 views

Difference between {{template "base" }} and {{template "base" .}} in go-gin

What is the difference between {{template "base" }} and {{template "base" .}}? I use go-gin, both can run with no problem. I cannot find any description in the documentation about this.
seokgyu's user avatar
  • 147
8 votes
2 answers
5k views

How To pass a function to template through c.HTML() in gin gonic framework (golang)

I want to pass a function through c.Html() function of type Context in gingonic. For example, if we want to pass a variable, we use c.HTML(http.StatusOK, "index", gin.H{ "user": user, ...
Vutuz's user avatar
  • 468