tent.io/lib/nav.rb
Jonathan Rudenberg c0ca040c2c Do stuff
2012-08-22 11:17:22 -04:00

14 lines
383 B
Ruby

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