Why am I seeing ZgotmplZ in my Go HTML template output?

后端 未结 6 969
执念已碎
执念已碎 2020-12-10 23:31

When I\'m calling a Go template function to output HTML, it displays ZgotmplZ.

Sample code:

http://play.golang.org/p/tfuJa_pFkm

         


        
6条回答
  •  暖寄归人
    2020-12-11 00:36

    You are trying to output HTML in a place where template/html thinks is unsafe (for example, inside an HTML element, like this:

    I cannot find any way to convince it it is safe (including returning template.HTML instead of string); the only alternative I have found is to rewrite the template, in this example use a bool output instead:

提交回复
热议问题