HTML in HAML issues

Skip to first unread message


May 30, 2014, 10:59:09 PM5/30/14
I've been at this for a few hours and cannot seem to figure it out.  I have a sinatra application, which retrieves a data from a database and creates a Post object.  A field/attribute of post is named content (ie:  post.content) , which contains html data.  I'm attempting to display this content "AS HTML" in haml, but not having any luck.

In my haml form I have an @post object.  The @post.content = <h1 style="text-align: center;">COOL</h1> <p>&nbsp;</p> <p>cool&nbsp;<span style="color: #ff0000;">beans</span>&nbsp;man</p> .
How do I display this in a haml page as actual html and not just a string of useless nonsense?

I've tried many things and it just displays the sting of html instead of actually displaying the html "AS HTML" in the page.

!= #{@post.content}
= @post.content

I've tried dozens of other methods posted online, but for the life of me cannot figure it out.  I think rails has something like html_safe.

If I put something like "<h1>HELLO</h1> in the haml page it displays fine.

Any help is greatly appreciated.  Thanks.
Reply all
Reply to author
0 new messages