Sha256: e2bfac013de49b92ca686197bcde54c75cf8b46302384fefc385ef2ed1d93d83
Contents?: true
Size: 1013 Bytes
Versions: 54
Compression:
Stored size: 1013 Bytes
Contents
module Locomotive module Steam module Liquid module Tags # Fetch a page from its handle and assign it to a liquid variable. # # Usage: # # {% fetch_page about_us as a_page %} # <p>{{ a_page.title }}</p> # class FetchPage < ::Liquid::Tag Syntax = /(#{::Liquid::VariableSignature}+)\s+as\s+(#{::Liquid::VariableSignature}+)/o def initialize(tag_name, markup, options) if markup =~ Syntax @handle, @var = $1, $2 else raise SyntaxError.new("Syntax Error in 'fetch_page' - Valid syntax: fetch_page page_handle as variable") end super end def render(context) page = context.registers[:repositories].page.by_handle(@handle) context.scopes.last[@var] = page '' end end ::Liquid::Template.register_tag('fetch_page'.freeze, FetchPage) end end end end
Version data entries
54 entries across 54 versions & 1 rubygems