Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't respect Delims #24

Open
js02sixty opened this issue Jul 21, 2019 · 0 comments · May be fixed by #47
Open

Doesn't respect Delims #24

js02sixty opened this issue Jul 21, 2019 · 0 comments · May be fixed by #47

Comments

@js02sixty
Copy link

Only works with default delims. Example doesn't work unless template uses "{{", "}}". Is there a way to get this to work?


import (
	"github.com/gin-contrib/multitemplate"
	"github.com/gin-gonic/gin"
)

type product struct {
	ID    int     `json:"id"`
	Name  string  `json:"name"`
	Price float32 `json:"price"`
	Color string  `json:"color"`
}

func main() {
	r := gin.Default()
	r.Delims("[%", "%]")
	r.HTMLRender = loadTemplates()
	r.GET("/product", func(c *gin.Context) {
		data := product{
			4,
			"toy car",
			12.40,
			"red",
		}
		c.HTML(200, "product", gin.H{"product": data})
	})
	r.Run(":3333")
}

func loadTemplates() multitemplate.Renderer {
	r := multitemplate.NewRenderer()
	r.AddFromFiles("product", "mytemplates/product.html")
	return r
}
@parnic parnic linked a pull request Jul 17, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant