How do I escape the ERB tag in ERB
Add a second % to the opening tag: label: body: “<%%= variable %>” The <%% sequence is valid ERB, rendered as a literal <%.
Add a second % to the opening tag: label: body: “<%%= variable %>” The <%% sequence is valid ERB, rendered as a literal <%.
Try to render template: <%= render :template => “controller/index” %> Or file: <%= render :template => “#{Rails.root}/app/controllers/controller/index” %> And I believe you should render it through controller, as far as it is more convenient: def your_action … render :action => :index end
<%== is equivalent to raw. From the Ruby on Rails Guide: To insert something verbatim use the raw helper rather than calling html_safe: <%= raw @cms.current_template %> <%# inserts @cms.current_template as is %> or, equivalently, use <%==: <%== @cms.current_template %> <%# inserts @cms.current_template as is %>
Try using raw(somePost.content). Alternatively, somePost.content.html_safe.
You’re trying to use render from assets. Unfortunately, it isn’t possible now, look at this.
As far as i know there is no way to do it directly and the reason is fairly simple too, html is executed at the server side and javascript is a client side language which means its executed in your local browser, thats why if you even try to pass a variable between the two … Read more
Considering Rails 3: html_safe actually “sets the string” as HTML Safe (it’s a little more complicated than that, but it’s basically it). This way, you can return HTML Safe strings from helpers or models at will. h can only be used from within a controller or view, since it’s from a helper. It will force … Read more
<% %> Executes the ruby code within the brackets. <%= %> Prints something into erb file. <%== %> Equivalent to <%= raw %>. Prints something verbatim (i.e. w/o escaping) into erb file. (Taken from Ruby on Rails Guides.) <% -%> Avoids line break after expression. <%# %> Comments out code within brackets; not sent to … Read more