class Navigatrix::Rendering::Strategies::Item

Attributes

options[R]

Public Class Methods

new(item, options = {}) click to toggle source
Calls superclass method
# File lib/navigatrix/rendering/strategies/item.rb, line 15
def initialize(item, options = {})
  super(item)
  @options = options || {}
end

Public Instance Methods

render() click to toggle source
# File lib/navigatrix/rendering/strategies/item.rb, line 20
def render
  content_tag(:li, content, html_attributes) if render?
end

Private Instance Methods

active_class() click to toggle source
Calls superclass method
# File lib/navigatrix/rendering/strategies/item.rb, line 76
def active_class
  super.presence || options[:active_class] || "active"
end
children_item_options() click to toggle source
# File lib/navigatrix/rendering/strategies/item.rb, line 96
def children_item_options
  children_options.fetch(:item, {})
end
children_list_options() click to toggle source
# File lib/navigatrix/rendering/strategies/item.rb, line 92
def children_list_options
  children_options.fetch(:list, {})
end
children_options() click to toggle source
# File lib/navigatrix/rendering/strategies/item.rb, line 68
def children_options
  options
end
children_renderer() click to toggle source
# File lib/navigatrix/rendering/strategies/item.rb, line 84
def children_renderer
  StrategyFactory.find_list_strategy(strategy_name)
end
content() click to toggle source
# File lib/navigatrix/rendering/strategies/item.rb, line 26
def content
  name_or_link + render_children
end
html_attributes() click to toggle source
Calls superclass method
# File lib/navigatrix/rendering/strategies/item.rb, line 46
def html_attributes
  universal_attributes
    .merge(super)
    .merge_attribute(:class, html_class)
end
html_class() click to toggle source
# File lib/navigatrix/rendering/strategies/item.rb, line 72
def html_class
  active? ? active_class : inactive_class
end
inactive_class() click to toggle source
Calls superclass method
# File lib/navigatrix/rendering/strategies/item.rb, line 80
def inactive_class
  super.presence || options[:inactive_class]
end
linked_content() click to toggle source
# File lib/navigatrix/rendering/strategies/item.rb, line 34
def linked_content
  link_to(name, path)
end
name() click to toggle source
Calls superclass method
# File lib/navigatrix/rendering/strategies/item.rb, line 42
def name
  super.html_safe
end
render_children() click to toggle source
# File lib/navigatrix/rendering/strategies/item.rb, line 56
def render_children
  if has_children?
    children_renderer.new(
      children,
      children_list_options,
      children_item_options
    ).render
  else
    ""
  end
end
strategy_name() click to toggle source
# File lib/navigatrix/rendering/strategies/item.rb, line 88
def strategy_name
  children_list_options[:renderer]
end
universal_attributes() click to toggle source
# File lib/navigatrix/rendering/strategies/item.rb, line 52
def universal_attributes
  HTMLAttributes.new(options[:html_attributes])
end
unlinked_content() click to toggle source
# File lib/navigatrix/rendering/strategies/item.rb, line 38
def unlinked_content
  name
end