Sha256: 66c4b788eb18a2fe97b96eb3ecd5ee70e774e990e1377ca8a1f2252da7d589a9
Contents?: true
Size: 714 Bytes
Versions: 1
Compression:
Stored size: 714 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 ||= {} options.reverse_merge!(tag: :li, root: nil) tag = options.delete(:tag) is_active = current_path?(path, options.delete(:root)) content_tag(tag, class: (:active if is_active)) 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.1.0 | lib/nav_helper.rb |