Class: Pakman::LiquidPageTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/pakman/liquid/template.rb

Overview

convenience helper for pages (with headers/front matter)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, opts = {}) ⇒ LiquidPageTemplate

Returns a new instance of LiquidPageTemplate.



49
50
51
# File 'lib/pakman/liquid/template.rb', line 49

def initialize( text, opts={} )
  @template = LiquidTemplate.new( text, opts )
end

Class Method Details

.from_file(path) ⇒ Object



36
37
38
39
40
41
# File 'lib/pakman/liquid/template.rb', line 36

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??



43
44
45
46
47
# File 'lib/pakman/liquid/template.rb', line 43

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



53
54
55
# File 'lib/pakman/liquid/template.rb', line 53

def render( hash )
  @template.render( hash )
end