Class: LocalPac::ErbGenerator
- Inherits:
-
Object
- Object
- LocalPac::ErbGenerator
- Defined in:
- lib/local_pac/erb_generator.rb
Overview
Used to generate the template
Instance Method Summary collapse
-
#compile(source, destination) ⇒ Object
Compile the template.
-
#initialize(data) ⇒ ErbGenerator
constructor
Create erb generator.
Constructor Details
#initialize(data) ⇒ ErbGenerator
Create erb generator
The data class to be used within the template
15 16 17 |
# File 'lib/local_pac/erb_generator.rb', line 15 def initialize(data) @data = data end |
Instance Method Details
#compile(source, destination) ⇒ Object
Compile the template
The source template to be used The output io handle
25 26 27 28 29 30 31 32 |
# File 'lib/local_pac/erb_generator.rb', line 25 def compile(source, destination) erb = ERB.new(source.read, nil, '-') begin destination.puts erb.result(data.instance_binding) rescue SyntaxError => e raise Exceptions::ErbTemplateHasSyntaxErrors, e. end end |