0
網站結構:多級菜單,活動鏈接css突出顯示。 (Ruby on Rails的)
/
/products
/products/design
/products/photo
/about
我想看看父菜單項也由CSS強調,當孩子處於活動狀態。
<li class="<%= current_page?(:action => 'design') %>">
<%= link_to_unless_current 'Design', :design %>
</li>
對於「產品:
我用這對兒童和簡單URL(在「設計」或「照片」是活動的「產品」也應該被突出顯示。) '檢查應該是這樣的:
<%= current_page?(:action => 'products') ||
current_page?(:action => 'design') %> ||
current_page?(:action => 'photo') %>
但是triple ||是不正確的,並且變得複雜。
我看到了一個幫手,像這樣的:
def current(childs)
if current_page?(:action => childs)
@container = "active"
else
@container = "inactive"
end
end
這是使用:<%= current(:photo) %>
那麼,怎樣才能把我所有的3個檢查 '產品', '設計',「照片'在一個幫手?
而且使得有可能使用類似<%= current(:products, :design, :photo) %>