Class: Locomotive::Liquid::Tags::FetchPage
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Locomotive::Liquid::Tags::FetchPage
- Defined in:
- lib/locomotive/liquid/tags/fetch_page.rb
Constant Summary collapse
Instance Method Summary collapse
-
#initialize(tag_name, markup, tokens, context) ⇒ FetchPage
constructor
A new instance of FetchPage.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, tokens, context) ⇒ FetchPage
Returns a new instance of FetchPage.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/locomotive/liquid/tags/fetch_page.rb', line 8 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 |
Instance Method Details
#render(context) ⇒ Object
19 20 21 22 |
# File 'lib/locomotive/liquid/tags/fetch_page.rb', line 19 def render(context) context.scopes.last[@var] = context.registers[:site].pages.where(handle: @handle).first '' end |