Rails 3 / HAML:如何从变量输出 haml raw?
我在 Rails 中有一些变量,其中包含一些 div,如下所示:
@layout_1 = "
.box_1
.column_4 <br>
.gutter<br>
.column_4<br>
.gutter<br>
.column_4<br>
.gutter<br>
.column_4<br>"
这是来自数据库,其想法是根据请求交换布局,但如何将变量 (@layout_1
) 输出为 HAML在 HAML 文件内?
如果我要使用普通的 html div,我会使用 <%=raw
或 .html_safe
I have some variables within rails that contain some divs like so:
@layout_1 = "
.box_1
.column_4 <br>
.gutter<br>
.column_4<br>
.gutter<br>
.column_4<br>
.gutter<br>
.column_4<br>"
This is coming from a database, and the idea is to swap layouts on request, but how can I output the variable (@layout_1
) as HAML inside a HAML file ?
If I were to use normal html divs, I would use <%=raw
or .html_safe
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您也可以在 .html.haml 视图文件中对 HAML 执行相同的操作。
或者
you would do the same with HAML as well in your .html.haml view file.
or
不完全确定这是否有效,但尝试一下:
Not entirely sure this works, but give it a try: