Class: TestServer::ErbGenerator
- Inherits:
-
Object
- Object
- TestServer::ErbGenerator
- Defined in:
- lib/test_server/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
16 17 18 |
# File 'lib/test_server/erb_generator.rb', line 16 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
26 27 28 29 30 31 32 33 |
# File 'lib/test_server/erb_generator.rb', line 26 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 |