My rails assistant displays '<' as '& lt;'! How to do it right?

I am working on a simple plugin here and it works far. Except for my assistant. This is a very simple helper, you just need to echo <span></span> for further javascript analysis.

The problem is that it does not output html correcty, replacing special characters with equivalent html code.

My plugin initializer:

 ActionView::Helpers.send :include, Test 

My plugin helper:

 module Test def only_for_testing render(:text => "<span></span>") end end 

When I call the only_for_testing helper inside the view, instead of rendering "<span></span>" it displays " &lt;span&gt;&lt;/span&gt; "

I tried to remove the render, return only the string, the same effect. I really do not want to create partial for this, because it is very simple HTML code, and its not for layout, its just for parsing.

Any idea what I might have done wrong here?

+6
source share
3 answers

Rails 3 replaces the default HTML in the view. You need to use the raw () helper or the "HTML line here" .html_safe

+16
source
 module Test def only_for_testing render(:html=> "<span></span>") end end 
+6
source

in rails 3.2, my helper did not recognize the ": html" character, but I believe that it was replaced with "inline", as this is what worked for me.

 module IndexHelper def logo render(:inline=> "<div class='css_name'></div>") end end 
+3
source

All Articles