V
V
v- death2015-11-09 22:27:47
go
v- death, 2015-11-09 22:27:47

Golang how to disable escape in html/template?

Hello. I wrote a function to load html

func Views(templateName string, l map[string]string, p map[string]string, w http.ResponseWriter, r *http.Request) {
  result := strings.Split(templateName, ";")
  var htm string
  
  for i := range result {
    bs, err := ioutil.ReadFile("kontrollers/html/" + result[i])
    if err != nil {
      Code404(w, r)
      ViewsErr("Страница не найдена! Внимание! Тревога! Код 404 - всем соблюдать панику!", w)
      return
    }
    htm = htm + string(bs)

  }

  t := template.New("html")
  t.Parse(htm)

  w.Header().Set("Content-Type", "text/html")
  t.Execute(w, map[string]map[string]string{
    "local": l,
    "game":  p,
  })

}

Works fine (the function is deliberately simplified. There is still html caching in RAM. But that's not the point)
If I want to pass the html in an array, then it will be converted to the html of the entity. How can I turn it off?
Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill, 2015-11-09
@vGrabko99

cast to template.HTML https://golang.org/pkg/html/template/#HTML

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question