tent.io/lib/nav.rb
Jonathan Rudenberg 68ce1aeaff Add docs
2012-08-22 14:04:09 -04:00

14 lines
435 B
Ruby

include Nanoc::Helpers::LinkTo
def nav_link_with_active(text, target, attributes = {})
target_path = target.is_a?(String) ? target : target.path
item_path = @item_rep.path.sub(/\..+/, '')
active = if attributes.delete(:top)
/^#{target_path}/ =~ item_path
else
target_path == item_path
end
"<li #{'class="active"' if active}>" + link_to(text, target, attributes) + "</li>"
end