使用HAML时,是否可以使用Heredoc或%Q {...}? [英] When using HAML, is there a way to use heredoc or %Q{ ... }?

查看:72
本文介绍了使用HAML时,是否可以使用Heredoc或%Q {...}?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许可以将其放入帮助程序中,但是现有的500行代码包含HAML代码中的所有内容,因此最好暂时遵循现有代码(在紧迫的期限内).

Maybe it can be put into a helper but the existing 500 lines of code has everything in the HAML code, so it is better to follow the existing code for the moment (for tight deadlines).

我发现现在唯一的工作方式是

I found the only way working right now is

- meta_tag = %Q{\n |
  <meta ...>\n |
  <meta ...>\n |
    [...]   \n |
  } |

将同时使用继续字符"和\n.如果可以简化,那就太好了.

which is to use the "continuation character" and the \n at the same time. It'd be great if it can be simplified.

推荐答案

一个好的方法是使用

A good way to do this would be to use the :ruby filter or load the needed content into a Ruby variable and pass it into HAML the normal way.

这篇关于使用HAML时,是否可以使用Heredoc或%Q {...}?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆