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.
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.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??
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 |