<%= h ...%>是什么?在Rails中意味着什么? [英] What does <%=h ... %> means in Rails?
本文介绍了<%= h ...%>是什么?在Rails中意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在此处找到了以下语法:
<%=h @person.first_name %>
h
是什么意思?
推荐答案
用于转义标签的输出以避免跨站点脚本编写。在rails 3中,它已更改为字符串的默认值(因此,您不必说逃避此字符串,而是说这是一个安全的字符串)。
It's for escaping the output of the tag to avoid cross-site-scripting. In rails 3, it's been changed to the default for a string (so rather than saying escape this string, you say, this is a safe string).
http://api.rubyonrails.org/classes/ERB/Util.html#method-ch
这篇关于<%= h ...%>是什么?在Rails中意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文