json_escape、 javascript_escape
json 和javascript 在 rails的html.erb 文件中需要转义
在html.erb文件中可以简写为 <%=j %>
html_escape 是对html进行转义,在rails3以上已经全部在<%= %> 中默认加载了
rails的文档: [url]http://api.rubyonrails.org/classes/ERB/Util.html[/url]
详细解释为什么要javascript转义: [url]http://stackoverflow.com/questions/1620113/why-escape-javascript-before-rendering-a-partial[/url]
json 和javascript 在 rails的html.erb 文件中需要转义
在html.erb文件中可以简写为 <%=j %>
html_escape 是对html进行转义,在rails3以上已经全部在<%= %> 中默认加载了
rails的文档: [url]http://api.rubyonrails.org/classes/ERB/Util.html[/url]
详细解释为什么要javascript转义: [url]http://stackoverflow.com/questions/1620113/why-escape-javascript-before-rendering-a-partial[/url]