Class: Slideshow::Service::LiquidTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/slideshow/service.rb

Overview

use our own litter liquid template handler

works like "original" in pakman template manager used by slideshow

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of LiquidTemplate.



203
204
205
# File 'lib/slideshow/service.rb', line 203

def initialize( text, opts={} )
  @template = Liquid::Template.parse( text )   # parses and compiles the template
end

Class Method Details

.from_file(path) ⇒ Object



191
192
193
194
195
# File 'lib/slideshow/service.rb', line 191

def self.from_file( path )
  puts "  Loading template (from file) >#{path}<..."
  text = File.read_utf8( path )     ## use/todo: use read utf8 - why? why not??
  self.new( text, path: path )   ## note: pass along path as an option
end

.from_public(name) ⇒ Object



197
198
199
200
201
# File 'lib/slideshow/service.rb', line 197

def self.from_public( name )
  path = "#{PUBLIC_FOLDER}/#{name}"
  puts "  Loading template (from builtin public) >#{path}<..."
  self.from_file( path )   ## note: pass along path as an option
end

Instance Method Details

#render(hash) ⇒ Object



207
208
209
210
211
# File 'lib/slideshow/service.rb', line 207

def render( hash )
  ## note: hash keys MUST be strings (not symbols) e.g. 'name' => 'Toby'
  ## pp hash
  @template.render( hash )
end