开发者

undocumented ERB syntax: <%=h ... %>

http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html lists a set of Recognized Tags - however, this list seems incomplete; for one thing it's missing the dash variant (<%- ... -%>, which suppresses line breaks IIRC).

Now I've come across another seemin开发者_运维问答gly undocumented variant:

<%=h some_variable %>
<%= link_to h(some_variable) ... %>

Google wouldn't tell me what that was all about; can anyone point me to an explanation?


It's not an ERB syntax. It is <%= ... %> and inside it is calling the ERB::Util.hmethod


h here is just a regular method, in fact it's an alias for html_escape.

http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB/Util.html#M000868

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜