Class: Pakman::LiquidPageTemplate
- Inherits:
-
Object
- Object
- Pakman::LiquidPageTemplate
- Defined in:
- lib/pakman/liquid/template.rb
Overview
convenience helper for pages (with headers/front matter)
Class Method Summary collapse
- .from_file(path) ⇒ Object
-
.from_string(text) ⇒ Object
use parse as alias - why?? why not??.
Instance Method Summary collapse
-
#initialize(text, opts = {}) ⇒ LiquidPageTemplate
constructor
A new instance of LiquidPageTemplate.
- #render(hash) ⇒ Object
Constructor Details
#initialize(text, opts = {}) ⇒ LiquidPageTemplate
Returns a new instance of LiquidPageTemplate.
58 59 60 |
# File 'lib/pakman/liquid/template.rb', line 58 def initialize( text, opts={} ) @template = LiquidTemplate.new( text, opts ) end |
Class Method Details
.from_file(path) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/pakman/liquid/template.rb', line 45 def self.from_file( path ) ## todo: (auto)-add headers as page.title etc. -- why? why not?? puts " Loading page template (from file) >#{path}<..." page = Page.from_file( path ) ## use/todo: use read utf8 - why? why not?? self.new( page.contents, path: path ) ## note: pass along path as an option end |
.from_string(text) ⇒ Object
use parse as alias - why?? why not??
52 53 54 55 56 |
# File 'lib/pakman/liquid/template.rb', line 52 def self.from_string( text ) ### use parse as alias - why?? why not?? ## todo: (auto)-add headers as page.title etc. -- why? why not?? page = Page.from_string( text ) self.new( page.contents ) end |
Instance Method Details
#render(hash) ⇒ Object
62 63 64 |
# File 'lib/pakman/liquid/template.rb', line 62 def render( hash ) @template.render( hash ) end |