Sha256: cd3cfdb844934f79afe38c1a921398527ce7b31542a210e41b7cbb3d22312e4d

Contents?: true

Size: 1.19 KB

Versions: 8

Compression:

Stored size: 1.19 KB

Contents

module Locomotive
  module Steam
    module Liquid
      module Drops

        # Section block drop
        class SectionBlock < ::Liquid::Drop

          def initialize(section, block, index)
            @section    = section
            @block      = block || { 'settings' => {} }
            @index      = index
            @leaves     = []
            @definition = section.definition['blocks'].find do |block|
              block['type'] == type
            end || {}
          end

          def id
            @block['id'] || @index
          end

          def type
            @block['type']
          end

          def depth
            @block['depth'].presence || 0
          end

          def leaves
            @leaves
          end

          def has_leaves?
            leaves.size > 0
          end

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

          def locomotive_attributes
            value = "section-#{@context['section'].id}-block-#{id}"
            %(data-locomotive-block="#{value}")
          end

        end

      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 lib/locomotive/steam/liquid/drops/section_block.rb
locomotivecms_steam-1.8.0.alpha1 lib/locomotive/steam/liquid/drops/section_block.rb
locomotivecms_steam-1.7.1 lib/locomotive/steam/liquid/drops/section_block.rb
locomotivecms_steam-1.7.0 lib/locomotive/steam/liquid/drops/section_block.rb
locomotivecms_steam-1.6.1 lib/locomotive/steam/liquid/drops/section_block.rb
locomotivecms_steam-1.6.0 lib/locomotive/steam/liquid/drops/section_block.rb
locomotivecms_steam-1.6.0.rc1 lib/locomotive/steam/liquid/drops/section_block.rb
locomotivecms_steam-1.6.0.beta1 lib/locomotive/steam/liquid/drops/section_block.rb