【发布时间】:2016-04-08 19:30:48
【问题描述】:
我有一个模板:
<script type="text/template" id="data-user">{{.User}}</script>
其中“用户”是 URL 编码格式的 json 字符串。类似的东西
%7Bdata%22%3A%5B%7B%7D%7D
但默认 html/template 将其放在引号内,如
"%7Bdata%22%3A%5B%7B%7D%7D"
我尝试了 html/template godoc reference 的那些东西
Context {{.}} After
{{.}} O'Reilly: How are <i>you</i>?
<a title='{{.}}'> O'Reilly: How are you?
<a href="/{{.}}"> O'Reilly: How are %3ci%3eyou%3c/i%3e?
<a href="?q={{.}}"> O'Reilly%3a%20How%20are%3ci%3e...%3f
<a onx='f("{{.}}")'> O\x27Reilly: How are \x3ci\x3eyou...?
<a onx='f({{.}})'> "O\x27Reilly: How are \x3ci\x3eyou...?"
<a onx='pattern = /{{.}}/;'> O\x27Reilly: How are \x3ci\x3eyou...\x3f
但我没有成功。 感谢您的帮助
【问题讨论】:
-
我觉得你应该看看this answer
-
谢谢!我在那里找到了一个提示!
标签: go go-html-template