Sha256: 2d062c0c93c32f6f4dbceaa99bca16112bd0b78bcfd281c5e486efb9414e9827

Contents?: true

Size: 778 Bytes

Versions: 22

Compression:

Stored size: 778 Bytes

Contents

module Locomotive
  module Liquid
    module Tags
      class FetchPage < ::Liquid::Tag
        
        Syntax = /(#{::Liquid::VariableSignature}+)\s+as\s+(#{::Liquid::VariableSignature}+)/
        
        def initialize(tag_name, markup, tokens, context)
          if markup =~ Syntax
            @handle = $1
            @var = $2
          else
            raise SyntaxError.new("Syntax Error in 'fetch_page' - Valid syntax: fetch_page page_handle as variable")
          end
          
          super
        end 
        
        def render(context)
          context.scopes.last[@var] = context.registers[:site].pages.where(handle: @handle).first
          ''
        end
      end
      
      ::Liquid::Template.register_tag('fetch_page', FetchPage)
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
locomotive_cms-2.5.5 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.5.4 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.5.3 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.5.2 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.5.1 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.5.0 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.5.0.rc3 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.5.0.rc2 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.5.0.rc1 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.4.1 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.4.0 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.3.1 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.3.0 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.2.3 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.2.2 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.2.1 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.2.0 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.1.4 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.1.3 lib/locomotive/liquid/tags/fetch_page.rb
locomotive_cms-2.1.2 lib/locomotive/liquid/tags/fetch_page.rb