Class: RackDispatch::TemplateDestination
- Inherits:
-
Object
- Object
- RackDispatch::TemplateDestination
- Defined in:
- lib/rack_dispatch/template_destination.rb
Instance Method Summary collapse
- #call(request, response) ⇒ Object
-
#initialize(path) ⇒ TemplateDestination
constructor
A new instance of TemplateDestination.
- #render(data = {}) ⇒ Object
Constructor Details
#initialize(path) ⇒ TemplateDestination
Returns a new instance of TemplateDestination.
3 4 5 |
# File 'lib/rack_dispatch/template_destination.rb', line 3 def initialize(path) @path = File.(File.join('templates', String(path)), Dir.pwd) + '.liquid' end |
Instance Method Details
#call(request, response) ⇒ Object
7 8 9 10 |
# File 'lib/rack_dispatch/template_destination.rb', line 7 def call(request, response) response['Content-Type'] = 'text/html' response.write(render(request.params)) end |
#render(data = {}) ⇒ Object
12 13 14 |
# File 'lib/rack_dispatch/template_destination.rb', line 12 def render(data = {}) Liquid::Template.parse(File.read(@path)).render(data) end |