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

how can I change the htmltemplate Tags #778

Closed
hxdhero opened this issue Dec 30, 2016 · 4 comments
Closed

how can I change the htmltemplate Tags #778

hxdhero opened this issue Dec 30, 2016 · 4 comments
Labels

Comments

@hxdhero
Copy link

hxdhero commented Dec 30, 2016

if i use html/template Delim ,i can't use html.rander in debug mode.

this caused me to restart the server everytime when i changed the template

@EtienneR
Copy link

I do something like this

// A custom function
func TemplateMe(c *gin.Context, page string, data interface{}) {
	tmpl, err := template.New("").Delims("[[", "]]").ParseFiles("views/view_layout.html", "views/"+page)

	if err != nil {
		http.Error(c.Writer, err.Error(), http.StatusInternalServerError)
	}

	tmpl.ExecuteTemplate(c.Writer, "layout", data)
}

// A handler
func indexHandler(c *gin.Context) {
	data := gin.H{"Title": "Hello World!"}
	TemplateMe(c, "view_login.html", data)
}

@shenshouer
Copy link
Contributor

I creat a PR for solve this. The PR is #860

@afiune
Copy link

afiune commented Jul 19, 2017

Should you guys close this since the PR got merged?

@appleboy
Copy link
Member

@afiune yes, see the following document.

https://github.com/gin-gonic/gin#custom-delimiters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants