我正在设置Foundation Zurb选项卡。
它看起来像这样:
- @items.group_by(&:calendar).each do |calendar, items|
%section
- # displaying tab name, which is Calendar name
- # displaying tab content, which is a table of Items for that Calendar
我希望第一个选项卡%section.active
,所有其他选项卡应该只是%section
(不活动)。
方法是什么?
如果通过取消拆分将初始两个变量组合在一起,则可以将每个变量与索引相加。
- @items.group_by(&:calendar).each_with_index do |(calendar, items), index|
%section{:class => ("active" if index.zero?)}
有关更多详细信息,请参阅此SO答案。