Css 如何设置动态类值?

Css 如何设置动态类值?,css,ruby-on-rails,haml,Css,Ruby On Rails,Haml,我有以下html.erb代码,我希望将其转移到Haml: <span class="<%= item.dashboardstatus.cssclass %>" ><%= item.dashboardstatus.status %></span> 它所做的是将当前分配状态的CSS类与范围相关联 在哈姆如何做到这一点?我肯定我错过了一些非常简单的东西。不确定。也许: %span{:class => item.dashboardstatus.

我有以下html.erb代码,我希望将其转移到Haml:

<span class="<%= item.dashboardstatus.cssclass %>" ><%= item.dashboardstatus.status %></span>

它所做的是将当前分配状态的CSS类与范围相关联

在哈姆如何做到这一点?我肯定我错过了一些非常简单的东西。

不确定。也许:

%span{:class => item.dashboardstatus.cssclass }= item.dashboardstatus.status
这起作用了

无论链接到什么地方,都可以这样做

  %div{"data-turbolinks" => "false"}
    = link_to 'Send payment', new_payments_manager_path(sender_id: current_user.id, receiver_id: @collaboration.with(current_user).id, collaboration_id: params[:id]), class: 'button'

可以使用数组语法执行多个条件类选择器:

%div{class:[(“active”if@thing.active?,(“highlight”if@thing.important?)]


您的解决方案与下面相同吗?如果您的标记不是直接html标记,而是通过rails帮助程序生成的,您该如何做?