How to output text containing html markup without having the browser render the html

I have an object attribute that constantly gets html inserted into it.
This becomes problematic when I want to output that attribute to the
browser. What I’d like to do is have the < and > converted to < and
>. Is there a snippet or plugin I can use to do this?

I have an object attribute that constantly gets html inserted into it.
This becomes problematic when I want to output that attribute to the
browser. What I’d like to do is have the < and > converted to < and
>. Is there a snippet or plugin I can use to do this?

Assuming your attribute is say @html_string

<%= h @html_string %>

-philip

You mean like the view helper h(), as in <%=h my_attr %>?

Exactly. Thank you.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs