Class: Storefront::Components::Header
- Defined in:
- lib/storefront/components/header.rb
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
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
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/storefront/components/header.rb', line 46 def (*args) = args. return if [:skip_format] return {} if [:title] == false header_html = [:header_html] || {} header_html.reverse_merge!(:class => config.header_class) title_html = [:title_html] || {} title_html.reverse_merge!(:class => config.title_class) title_html[:value] = .delete(:title) title_html[:value] = t?(title_html[:value], :scope => :"widgets.headers") if title_html[:value].is_a?(::Symbol) subtitle_html = [:subtitle_html] || {} if subtitle_html.present? || [:subtitle].present? subtitle_html.reverse_merge!(:class => config.subtitle_class) subtitle_html[:value] = .delete(:subtitle) subtitle_html[:value] = t?(subtitle_html[:value], :scope => :"widgets.headers") if subtitle_html[:value].is_a?(::Symbol) end .merge! :header_html => header_html, :title_html => title_html, :subtitle_html => subtitle_html end |
#render(&block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/storefront/components/header.rb', line 4 def render(&block) return nil if .blank? template.capture_haml do if block_given? && !pointer.include?("footer") template.haml_tag :header, [:header_html], &block elsif [:header] == false || pointer.include?("footer") render_titles else if [:title_html][:value].present? template.haml_tag :header, [:header_html] do render_titles end else template.haml_tag :header, [:header_html] end end end end |
#render_titles ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/storefront/components/header.rb', line 24 def render_titles level = [:level] || config.default_component_header_level title = [:title_html].delete(:value) subtitle = [:subtitle_html].delete(:value) if title.present? if subtitle.present? if [:header] == false || pointer.include?("footer") template.haml_tag :"h#{level}", title, [:title_html] template.haml_tag :"h#{level + 1}", subtitle, [:subtitle_html] else template.haml_tag :hgroup do template.haml_tag :"h#{level}", title, [:title_html] template.haml_tag :"h#{level + 1}", subtitle, [:subtitle_html] end end else template.haml_tag :"h#{level}", title, [:title_html] end end end |