Class: Storefront::Components::DefinitionListItem
- Defined in:
- lib/storefront/components/definition_list_item.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
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/storefront/components/definition_list_item.rb', line 23 def (*args) = args. key = args.shift || [:key] value = args.shift || [:value] unless key.nil? = .delete(:locale_options) || {} label = t?(key, .reverse_merge(:scope => :"terms.labels")) if [:auto_id] == true && !value.nil? id_base = label.underscore.strip.gsub(/[\s|_]+/, config.separator).squeeze(config.separator) end key_html = .delete(:key_html) || {} merge_class! key_html, config.term_key_class key_html[:lang] = [:lang] if [:lang] if id_base key_html[:id] ||= "#{id_base}-key" end separator = [:separator] || @separator label.gsub!(/#{separator}?$/, separator) if separator.present? end value_html = .delete(:value_html) || {} merge_class! value_html, config.term_value_class if id_base value_html[:id] ||= "#{id_base}-value" end if config.include_aria value_html[:role] ||= :definition value_html[:"aria-labelledby"] = key_html[:id] if key_html && key_html[:id] #value_html[:"aria-describedby"] = hint_html[:id] end .merge( :key => label, :key_html => key_html, :value => value, :value_html => value_html ) 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/definition_list_item.rb', line 4 def render(&block) template.capture_haml do unless [:key].nil? if [:definition] == true template.haml_tag :dt, template.haml_tag(:dfn, [:key]), [:key_html] else template.haml_tag :dt, [:key], [:key_html] end end if block_given? # i.e. multiple definitions for a term template.haml_tag :dd, [:value_html], &block else template.haml_tag :dd, [:value], [:value_html] unless [:value].nil? end end end |