Class: Pakman::ErbTemplate
- Inherits:
-
Object
- Object
- Pakman::ErbTemplate
- Defined in:
- lib/pakman/erb/template.rb
Class Method Summary collapse
- .from_file(path) ⇒ Object
-
.from_string(text) ⇒ Object
use parse as alias - why?? why not??.
Instance Method Summary collapse
-
#initialize(text, opts = {}) ⇒ ErbTemplate
constructor
A new instance of ErbTemplate.
- #render(binding) ⇒ Object
Constructor Details
#initialize(text, opts = {}) ⇒ ErbTemplate
Returns a new instance of ErbTemplate.
18 19 20 |
# File 'lib/pakman/erb/template.rb', line 18 def initialize( text, opts={} ) @template = ERB.new( text ) end |
Class Method Details
.from_file(path) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/pakman/erb/template.rb', line 7 def self.from_file( path ) ## todo/fix: update logutils - (auto-)add ("static") logger helper/mixin too!!!!! LogKernel::Logger[ self ].info " Loading template (from file) >#{path}<..." text = File.open( path, 'r:bom|utf-8' ).read ## note: assume utf8 self.new( text, path: path ) ## note: pass along path as an option end |
.from_string(text) ⇒ Object
use parse as alias - why?? why not??
14 15 16 |
# File 'lib/pakman/erb/template.rb', line 14 def self.from_string( text ) ### use parse as alias - why?? why not?? self.new( text ) end |
Instance Method Details
#render(binding) ⇒ Object
22 23 24 |
# File 'lib/pakman/erb/template.rb', line 22 def render( binding ) @template.result( binding ) end |