Class: Locomotive::Steam::Liquid::Tags::FetchPage
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Locomotive::Steam::Liquid::Tags::FetchPage
- Defined in:
- lib/locomotive/steam/liquid/tags/fetch_page.rb
Overview
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>
Constant Summary collapse
Instance Method Summary collapse
-
#initialize(tag_name, markup, options) ⇒ FetchPage
constructor
A new instance of FetchPage.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, options) ⇒ FetchPage
Returns a new instance of FetchPage.
17 18 19 20 21 22 23 24 25 |
# File 'lib/locomotive/steam/liquid/tags/fetch_page.rb', line 17 def initialize(tag_name, markup, ) 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 |
Instance Method Details
#render(context) ⇒ Object
27 28 29 30 31 |
# 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 |