jay*_*jay 34 html css ruby-on-rails ruby-on-rails-3 slim-lang
在rails slim(http://slim-lang.com/)中,定义具有类名"sample"的新div的语法如下:
.sample
= "Content goes here"
Run Code Online (Sandbox Code Playgroud)
这将创建:
<div class="sample">
Content goes here
</div>
Run Code Online (Sandbox Code Playgroud)
我想根据铁路的助手,变量或其他东西来定义div的类......比如,在rails中:
<div class="sample #{@variable.name}">
Content goes here
</div>
Run Code Online (Sandbox Code Playgroud)
我不知道如何在苗条中做到这一点:
.sample #what else goes here?
Content goes here
Run Code Online (Sandbox Code Playgroud)
谁知道怎么样?
Zab*_*bba 56
怎么样
div[class="sample #{@variable.name}"]
Run Code Online (Sandbox Code Playgroud)
甚至
div class=["sample", @variable.name]
Run Code Online (Sandbox Code Playgroud)
要么
.sample *{:class => [@variable1.name, @variable2.name]}
Run Code Online (Sandbox Code Playgroud)
您可以使用括号,花括号或仅使用空格
.first-class(class="second-class-#{ruby_call}")
.first-class *{class: "second-class-#{ruby_call}"}
.first-class class="second-class-#{ruby_call}"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
23486 次 |
最近记录: |