Go lang templates: always quotes a string and removes comments

女生的网名这么多〃 提交于 2019-12-05 23:45:49

The html/template package is expressly designed to escape values. In your case, you're trying to pass JavaScript code in, rather than a simple value. You can accomplish this by changing the type of UserEmail to that of template.JS. This type wraps a string and expresses the intent that this value is valid JavaScript and should be substituted directly (without quotes) when used in a JavaScript context.

This version of the code does precisely that: http://play.golang.org/p/aNGnFMyY1O

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!