steven_noble
steven_noble

Reputation: 4203

Is there an equivalent of raw for displaying haml stored in an instance variable

In /views/documents/show.html.haml, I have:

= raw @document.content

If @document.content stores HTML, such as <p>foo</p>, I see "foo" formatted as a paragraph.

But if @document.content stores HAML, such as %p foo, I see the entered code, rather than "foo" formatted as a paragraph.

The same happens if I use...

   = @document.content

...without the raw.

Is there a solution?

Upvotes: 0

Views: 140

Answers (1)

steven_noble
steven_noble

Reputation: 4203

Answer was:

- engine = Haml::Engine.new(@document.content)
= engine.render

Upvotes: 1

Related Questions