class Locomotive::Steam::Liquid::Tags::FetchPage

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>

Constants

Syntax

Public Class Methods

new(tag_name, markup, options) click to toggle source
Calls superclass method
# File lib/locomotive/steam/liquid/tags/fetch_page.rb, line 17
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

Public Instance Methods

render(context) click to toggle source
# File lib/locomotive/steam/liquid/tags/fetch_page.rb, line 27
def render(context)
  page = context.registers[:repositories].page.by_handle(@handle)
  context.scopes.last[@var] = page
  ''
end