Sha256: 91d5c83f6e903ab3bf7ee33d5e99f66a2b98226bcdb4678bb8619319159902bd
Contents?: true
Size: 906 Bytes
Versions: 12
Compression:
Stored size: 906 Bytes
Contents
module Madmin::NavHelper def nav_link_to(name = nil, options = {}, html_options = {}, &block) if block html_options = options options = name name = block end url = url_for(options) starts_with = html_options.delete(:starts_with) html_options[:class] = Array.wrap(html_options[:class]) active_class = html_options.delete(:active_class) || "active" inactive_class = html_options.delete(:inactive_class) || "" active = if (paths = Array.wrap(starts_with)) && paths.present? paths.any? { |path| request.path.start_with?(path) } else request.path == url end classes = active ? active_class : inactive_class html_options[:class] << classes unless classes.empty? html_options.except!(:class) if html_options[:class].empty? return link_to url, html_options, &block if block link_to name, url, html_options end end
Version data entries
12 entries across 12 versions & 1 rubygems