Class: RackDispatch::TemplateHandler
- Inherits:
-
Object
- Object
- RackDispatch::TemplateHandler
- Defined in:
- lib/rack_dispatch/template_handler.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(path, status: 200, content_type: 'text/html', error: nil) ⇒ TemplateHandler
constructor
A new instance of TemplateHandler.
Constructor Details
#initialize(path, status: 200, content_type: 'text/html', error: nil) ⇒ TemplateHandler
Returns a new instance of TemplateHandler.
3 4 5 6 7 8 |
# File 'lib/rack_dispatch/template_handler.rb', line 3 def initialize(path, status: 200, content_type: 'text/html', error: nil) @path = File.(File.join('templates', path), Dir.pwd) @status = Integer(status) @content_type = String(content_type) @error = error end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/rack_dispatch/template_handler.rb', line 10 def call [ @status, { 'Content-Type' => @content_type, }, [ERB.new(File.read(@path)).result(OpenStruct.new(template_variables).instance_eval { binding })], ] end |