In rails slim (http://slim-lang.com/) the syntax for defining a new div with a class name "sample" is the following:
.sample
= "Content goes here"
this will create:
<div class="sample">
Content goes here
</div>
I want to define a div's class according to a rail's helper, a variable, or other things.. such as, in rails:
<div class="sample #{@variable.name}">
Content goes here
</div>
I have no idea how to do this in slim:
.sample #what else goes here?
Content goes here
Anyone know how?
How about
div[class="sample #{@variable.name}"]
or even
div class=["sample", @variable.name]
or
.sample *{:class => [@variable1.name, @variable2.name]}
You can use parentheses, curly braces or just a space
.first-class(class="second-class-#{ruby_call}")
.first-class *{class: "second-class-#{ruby_call}"}
.first-class class="second-class-#{ruby_call}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With