使用Slim使用Rails动态设置类

时间:2015-09-22 22:56:25

标签: css ruby-on-rails-4 slim-lang

我正在试图弄清楚如何在slim(Rails 4)中设置动态类。这就是我正在尝试的...基于我在erb中的表现。

package soy.wimmer;                                                              

import cucumber.api.PendingException;                                            
import cucumber.api.java8.En;                                                    

public class CucumberStepdefs implements En {                                    
    public CucumberStepdefs() {                                                  
        Given("^I have some dummy code$", () -> {                                
            // Write code here that turns the phrase above into concrete actions 
            throw new PendingException();                                        
        });                                                                      

        When("^I try to test it$", () -> {                                       
            // Write code here that turns the phrase above into concrete actions 
            throw new PendingException();                                        
        });                                                                      

        Then("^it should work with cucumber-java(\\d+)$", (Integer arg1) -> {    
            // Write code here that turns the phrase above into concrete actions 
            throw new PendingException();                                        
        });                                                                      
    }                                                                            
}

1 个答案:

答案 0 :(得分:3)

这应该做!

li class="#{'current' if user.id == current_user.id}"

基本上,class=anything_that_evaluates_to_string。这适用于各种属性。