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.h
method
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
精彩评论