Class: Pakman::ErbTemplate

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ErbTemplate.



17
18
19
# File 'lib/pakman/erb/template.rb', line 17

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

Class Method Details

.from_file(path) ⇒ Object



7
8
9
10
11
# File 'lib/pakman/erb/template.rb', line 7

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

.from_string(text) ⇒ Object

use parse as alias - why?? why not??



13
14
15
# File 'lib/pakman/erb/template.rb', line 13

def self.from_string( text )  ### use parse as alias - why?? why not??
  self.new( text )
end

Instance Method Details

#render(binding) ⇒ Object



21
22
23
# File 'lib/pakman/erb/template.rb', line 21

def render( binding )
  @template.result( binding )
end