Reputation: 32548
I'm using template
to export "
in go but it returns only "
. Is there a way to get it to export "
instead.
import (
"html/template"
)
//Testf a test function
func Testf() string {
return "\""
}
//MapToFunctions Map actions to functions
var MapToFunctions = template.FuncMap{
"testf": Testf}
Then, to use in a file, I'd put {{ testf }}
Upvotes: 1
Views: 1630
Reputation: 2463
That is because html/template
will make it html safe which escapes all the html special characters and replacing them with html encoding.
In order to avoid that, you should replace html/template
with text/template
Upvotes: 6