Class: Locomotive::Steam::Liquid::Drops::Section
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Locomotive::Steam::Liquid::Drops::Section
- Defined in:
- lib/locomotive/steam/liquid/drops/section.rb
Instance Method Summary collapse
- #anchor_id ⇒ Object
- #blocks ⇒ Object
- #css_class ⇒ Object
- #editor_setting_data ⇒ Object
-
#id ⇒ Object
FIXME: id acts as the domID to build HTML tags.
- #id=(id) ⇒ Object
-
#initialize(section, content) ⇒ Section
constructor
A new instance of Section.
- #locomotive_attributes ⇒ Object
- #settings ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(section, content) ⇒ Section
Returns a new instance of Section.
8 9 10 11 12 13 14 15 |
# File 'lib/locomotive/steam/liquid/drops/section.rb', line 8 def initialize(section, content) @section = section @content = content if @content.blank? @content = section.definition['default'] || { 'settings' => {}, 'blocks' => [] } end end |
Instance Method Details
#anchor_id ⇒ Object
41 42 43 |
# File 'lib/locomotive/steam/liquid/drops/section.rb', line 41 def anchor_id "#{@content['anchor'] || id}-section" end |
#blocks ⇒ Object
53 54 55 56 57 |
# File 'lib/locomotive/steam/liquid/drops/section.rb', line 53 def blocks (@content['blocks'] || []).each_with_index.map do |block, index| SectionBlock.new(@section, block, index) end end |
#css_class ⇒ Object
37 38 39 |
# File 'lib/locomotive/steam/liquid/drops/section.rb', line 37 def css_class @section.definition['class'] end |
#editor_setting_data ⇒ Object
59 60 61 |
# File 'lib/locomotive/steam/liquid/drops/section.rb', line 59 def editor_setting_data SectionEditorSettingData.new(@section) end |
#id ⇒ Object
FIXME: id acts as the domID to build HTML tags
18 19 20 |
# File 'lib/locomotive/steam/liquid/drops/section.rb', line 18 def id @content['id'] end |
#id=(id) ⇒ Object
22 23 24 |
# File 'lib/locomotive/steam/liquid/drops/section.rb', line 22 def id=(id) @content['id'] = id end |
#locomotive_attributes ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/locomotive/steam/liquid/drops/section.rb', line 45 def locomotive_attributes %(data-locomotive-section-id="#{id}" data-locomotive-section-type="#{type}").tap do # let Steam know that we won't need to wrap the section HTML # into an extra DIV layer. @context['is_section_locomotive_attributes_displayed'] = true end end |
#settings ⇒ Object
30 31 32 33 34 35 |
# File 'lib/locomotive/steam/liquid/drops/section.rb', line 30 def settings @content_proxy ||= SectionContentProxy.new( @content['settings'] || {}, @section.definition['settings'] || [] ) end |
#type ⇒ Object
26 27 28 |
# File 'lib/locomotive/steam/liquid/drops/section.rb', line 26 def type @section.type end |