Class: Slideshow::Service::LiquidTemplate
- Inherits:
-
Object
- Object
- Slideshow::Service::LiquidTemplate
- 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
-
#initialize(text, opts = {}) ⇒ LiquidTemplate
constructor
A new instance of LiquidTemplate.
- #render(hash) ⇒ Object
Constructor Details
#initialize(text, opts = {}) ⇒ LiquidTemplate
Returns a new instance of LiquidTemplate.
174 175 176 |
# File 'lib/slideshow/service.rb', line 174 def initialize( text, opts={} ) @template = Liquid::Template.parse( text ) # parses and compiles the template end |
Class Method Details
.from_file(path) ⇒ Object
162 163 164 165 166 |
# File 'lib/slideshow/service.rb', line 162 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
168 169 170 171 172 |
# File 'lib/slideshow/service.rb', line 168 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
178 179 180 181 182 |
# File 'lib/slideshow/service.rb', line 178 def render( hash ) ## note: hash keys MUST be strings (not symbols) e.g. 'name' => 'Toby' ## pp hash @template.render( hash ) end |