Rails 3 / HAML: How can I infer haml raw from a variable?

I have some variables in rails that contain some divs, for example:

@layout_1 = " .box_1 .column_4 <br> .gutter<br> .column_4<br> .gutter<br> .column_4<br> .gutter<br> .column_4<br>" 

This comes from the database, and the idea is to replace the layouts on demand, but how can I output the variable ( @layout_1 ) as HAML inside the HAML file?

If I used regular html .html_safe , I would use <%=raw or .html_safe

+4
source share
2 answers

you would do the same with HAML as well as in your .html.haml view file.

 = raw @layout_1 

or

 = @layout_1.html_safe 
+11
source

Not quite sure if this works, but try:

 - output = Haml::Engine.new(@layout1).render != output 
+5
source

Source: https://habr.com/ru/post/1387099/


All Articles