你能在HAML css中插入ruby变量吗?

我需要一系列类,.module1,.module2,… module(n)。

我还想使用css,ruby和HAML定义这些类:

:css .mod1 { background-image: url("#{extra.image}"); } 

是否可以插入ruby变量以节省工作量?

 .module.mod"#{extra.id}" %h3 #{extra.title} %p #{extra.description} %a.btn-default{:href => "#", :target => "_top"} enter now :css .mod#{extra.id} { background-image: url("#{extra.image}"); } 

根据HAML_REFERENCE我使用这种方法:

 - flavor = "raspberry" #content :textile I *really* prefer _#{h flavor}_ jam. 

在以下后面插入变量:css

 .module.modone{:class => "#{cycle("mod_#{extra.id}_")}"} %h3 #{extra.title} %p #{extra.description} %a.btn-default{:href => "#", :target => "_top"} enter now :css .mod_#{extra.id}_ { background-image: url("#{extra.image}"); background-color: #4073DF; }