class Bootstrap::ActiveLinkTo::ActiveLink
Constants
- ACTIVE_OPTIONS
Public Class Methods
new(context)
click to toggle source
# File lib/bootstrap/active_link_to.rb, line 8 def initialize(context) @context = context end
Public Instance Methods
render(*args, &block)
click to toggle source
# File lib/bootstrap/active_link_to.rb, line 12 def render(*args, &block) @name = block_given? ? capture(&block) : args.shift @link_options = args.extract_options! @url = h.url_for(args.shift) @active_options = @link_options.extract!(*ACTIVE_OPTIONS).only_presented @after_link = @link_options.delete(:after_link).to_s if is_wrap? provide_wrap_with_content! else @link_options.smart_append_to :class, active_class content end end
Private Instance Methods
active_class()
click to toggle source
# File lib/bootstrap/active_link_to.rb, line 75 def active_class h.active_link_to_class(@url, @active_options, is_active?) end
content()
click to toggle source
# File lib/bootstrap/active_link_to.rb, line 28 def content "#{link}#{@after_link}".html_safe end
h()
click to toggle source
# File lib/bootstrap/active_link_to.rb, line 32 def h @context end
is_active?()
click to toggle source
# File lib/bootstrap/active_link_to.rb, line 41 def is_active? @is_active = h.is_active_link?(@url, @active_options[:active]) if @is_active.nil? @is_active end
is_active_disable?()
click to toggle source
# File lib/bootstrap/active_link_to.rb, line 54 def is_active_disable? !!@active_options[:active_disable] end
is_dropdown?()
click to toggle source
# File lib/bootstrap/active_link_to.rb, line 50 def is_dropdown? !@link_options[:dropdown].nil? end
is_wrap?()
click to toggle source
# File lib/bootstrap/active_link_to.rb, line 46 def is_wrap? !@link_options[:wrap_tag].nil? end
link()
click to toggle source
# File lib/bootstrap/active_link_to.rb, line 36 def link return @name if is_active? && is_active_disable? h.link_to @name, @url, @link_options end
provide_dropdown!()
click to toggle source
# File lib/bootstrap/active_link_to.rb, line 68 def provide_dropdown! dropdown_html, dropdown = @link_options.extract!(:dropdown_html, :dropdown).values @wrap_options.smart_append_to :class, 'dropdown' @link_options.smart_update class: ['dropdown-toggle'], id: dropdown, data: {toggle: 'dropdown', hover: 'dropdown'} @after_link << dropdown_html.to_s end
provide_wrap_with_content!()
click to toggle source
# File lib/bootstrap/active_link_to.rb, line 58 def provide_wrap_with_content! @link_options[:wrap_options] ||= {} @wrap_options, wrap_tag = @link_options.extract!(:wrap_options, :wrap_tag).values @wrap_options.smart_append_to :class, active_class provide_dropdown! if is_dropdown? h.content_tag wrap_tag, content, @wrap_options end