Sha256: bf6225b9cff218e892db84d266bba7969486749c5f31754018df30edef0c3c93

Contents?: true

Size: 1022 Bytes

Versions: 13

Compression:

Stored size: 1022 Bytes

Contents

module Locomotive
  module Steam
    module Liquid
      module Tags

        class Hybrid < ::Liquid::Block

          def render_as_block?
            @render_as_block
          end

          def parse(tokens)
            if @render_as_block = find_block_delimiter?(tokens)
              super
            else
              @body  = nil
              @blank = false
            end
          end

          def find_block_delimiter?(tokenizer)
            tokenizer.instance_variable_get(:@tokens).each do |token|
              next if token.empty?
              if token.start_with?(::Liquid::BlockBody::TAGSTART)
                if token =~ ::Liquid::BlockBody::FullToken
                  return false  if Regexp.last_match(1) == @tag_name
                  return true   if Regexp.last_match(1) == block_delimiter
                end
              end
            end
            false
          end

          def nodelist
            @body&.nodelist || []
          end

        end

      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 lib/locomotive/steam/liquid/tags/hybrid.rb
locomotivecms_steam-1.8.0.alpha1 lib/locomotive/steam/liquid/tags/hybrid.rb
locomotivecms_steam-1.7.1 lib/locomotive/steam/liquid/tags/hybrid.rb
locomotivecms_steam-1.7.0 lib/locomotive/steam/liquid/tags/hybrid.rb
locomotivecms_steam-1.6.1 lib/locomotive/steam/liquid/tags/hybrid.rb
locomotivecms_steam-1.6.0 lib/locomotive/steam/liquid/tags/hybrid.rb
locomotivecms_steam-1.6.0.rc1 lib/locomotive/steam/liquid/tags/hybrid.rb
locomotivecms_steam-1.6.0.beta1 lib/locomotive/steam/liquid/tags/hybrid.rb
locomotivecms_steam-1.5.3 lib/locomotive/steam/liquid/tags/hybrid.rb
locomotivecms_steam-1.5.2 lib/locomotive/steam/liquid/tags/hybrid.rb
locomotivecms_steam-1.5.1 lib/locomotive/steam/liquid/tags/hybrid.rb
locomotivecms_steam-1.5.0 lib/locomotive/steam/liquid/tags/hybrid.rb
locomotivecms_steam-1.5.0.rc1 lib/locomotive/steam/liquid/tags/hybrid.rb