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