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.



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