Sha256: f152877fe4774994165ac48e916fc3204550c67817780d09b9cb427ae62f2631

Contents?: true

Size: 1.64 KB

Versions: 5

Compression:

Stored size: 1.64 KB

Contents

module Locomotive
  module Steam
    module Liquid
      module Drops

        class Section < ::Liquid::Drop

          def initialize(section, content)
            @section    = section
            @content    = content

            if @content.blank?
              @content = section.definition['default'] || { 'settings' => {}, 'blocks' => [] }
            end
          end

          # FIXME: id acts as the domID to build HTML tags
          def id
            @content['id']
          end

          def id=(id)
            @content['id'] = id
          end

          def type
            @section.type
          end

          def settings
            @content_proxy ||= SectionContentProxy.new(
              @content['settings'] || {},
              @section.definition['settings'] || []
            )
          end

          def css_class
            @section.definition['class']
          end

          def anchor_id
            "#{@content['anchor'] || id}-section"
          end

          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

          def blocks
            (@content['blocks'] || []).each_with_index.map do |block, index|
              SectionBlock.new(@section, block, index)
            end
          end

          def editor_setting_data
            SectionEditorSettingData.new(@section)
          end

        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
locomotivecms_steam-1.5.3 lib/locomotive/steam/liquid/drops/section.rb
locomotivecms_steam-1.5.2 lib/locomotive/steam/liquid/drops/section.rb
locomotivecms_steam-1.5.1 lib/locomotive/steam/liquid/drops/section.rb
locomotivecms_steam-1.5.0 lib/locomotive/steam/liquid/drops/section.rb
locomotivecms_steam-1.5.0.rc1 lib/locomotive/steam/liquid/drops/section.rb