JZ.*_*JZ. 10 css ruby haml interpolation ruby-on-rails
我需要一系列类,.module1,.module2,... module(n).
我还想使用css,ruby和HAML定义这些类:
:css
.mod1 {
background-image: url("#{extra.image}");
}
Run Code Online (Sandbox Code Playgroud)
是否可以插入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}");
}
Run Code Online (Sandbox Code Playgroud)
JZ.*_*JZ. 13
根据HAML_REFERENCE我使用这种方法:
- flavor = "raspberry"
#content
:textile
I *really* prefer _#{h flavor}_ jam.
Run Code Online (Sandbox Code Playgroud)
在以下后面插入变量: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;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6898 次 |
最近记录: |