Class: Storefront::Components::Menu

Inherits:
Base
  • Object
show all
Defined in:
lib/storefront/components/menu.rb

Constant Summary

Constant Summary

Constants included from Helpers::ContentHelper

Helpers::ContentHelper::SCOPES, Helpers::ContentHelper::SCOPES_WITH_NAMESPACE, Helpers::ContentHelper::SCOPES_WITH_NAMESPACE_AND_NESTED_MODEL, Helpers::ContentHelper::SCOPES_WITH_NESTED_MODEL

Instance Attribute Summary

Attributes inherited from Base

#options, #template

Instance Method Summary collapse

Methods inherited from Base

#component_name, #extract_classes!, #initialize, #inside?, #pointer, #render_with_pointer, #to_s

Methods included from Helpers::ContentHelper

#encoded_contents, #font_face_data_uri, #html5_time, #read_binary_file, #read_image_size, #rendered_text, #sanitize, #t?

Constructor Details

This class inherits a constructor from Storefront::Components::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Storefront::Components::Base

Instance Method Details

#extract_options!(*args) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/storefront/components/menu.rb', line 22

def extract_options!(*args)
  options = super(*args)
  
  options[:tag] ||= :ol
  options[:inner_html] ||= {}
  
  if config.include_aria
    options[:outer_html][:role] ||= :menu
    options[:inner_html][:role] ||= :list
  end
  
  merge_class! options[:inner_html], *[
    "list"
  ]
  
  options
end

#render(&block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/storefront/components/menu.rb', line 4

def render(&block)
  template.capture_haml do
    template.haml_tag :nav, options[:outer_html] do
      header = template.header_widget(options)
      
      if header.present?
        template.haml_concat header
      end
      
      template.haml_tag options[:tag], options[:inner_html], &block
      
      if options[:footer_html].present?
        template.footer_widget(options[:footer_html])
      end
    end
  end
end