Sha256: 74f1f322f57f97d20b62e80bcd4c3754878ae44bc2b2d43ef449fe47c1c55ced
Contents?: true
Size: 848 Bytes
Versions: 1
Compression:
Stored size: 848 Bytes
Contents
require "nav_helper/version" module NavigationHelper def current_path request.path end def current_path?(path, root = '/') if path == root current_path == path else (/\A#{path}(\/.*)?\Z/ =~ current_path).present? end end def nav_item(title, path = nil, options = nil, &blk) path, options = title, path if block_given? options ||= {} root = options.delete(:root) active_class = options.delete(:active_class) || 'active' wrapper = options.delete(:wrapper) || {} tag = wrapper.delete(:tag) || :li if current_path?(path, root) wrapper[:class] = [ wrapper[:class], active_class ].compact.join(' ') end content_tag(tag, wrapper) do if block_given? link_to(path, options, &blk) else link_to(title, path, options) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nav_helper-0.2.0 | lib/nav_helper.rb |