Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ruby

erb

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 seemingly 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?

like image 614
AnC Avatar asked Feb 07 '26 15:02

AnC


1 Answers

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

like image 165
Serabe Avatar answered Feb 09 '26 10:02

Serabe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!