Html/template Delims



Can I change the “html / template” delimiter?

I tried to do something like that, but it does not work.

func (t *TemplateRenderer) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
	t.templates.Delims("[[", "]]")

	// Add global methods if data is a map
	if viewContext, isMap := data.(map[string]interface{}); isMap {
		viewContext["reverse"] = c.Echo().Reverse

	return t.templates.ExecuteTemplate(w, name, data)

Thank you!


@suporte What error are you getting?


No error, just does not respect the configuration.


@suporte I don’t think we do anything special for the templates in the framework. Can you try it without the framework?

#5 - I quote

“Delims sets the action delimiters to the specified strings, to be used in subsequent calls to Parse, ParseFiles, or ParseGlob.”

In the example above, Delims() is called right before executing the template, but after it was parsed, which is why it is ignored.