Class: Locomotive::Steam::Server::Renderer

Inherits:
Middleware
  • Object
show all
Defined in:
lib/locomotive/steam/server/renderer.rb

Instance Attribute Summary

Attributes inherited from Middleware

#app, #content_entry, #liquid_assigns, #mounting_point, #page, #path, #request

Instance Method Summary collapse

Methods inherited from Middleware

#initialize

Constructor Details

This class inherits a constructor from Locomotive::Steam::Server::Middleware

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/locomotive/steam/server/renderer.rb', line 6

def call(env)
  self.set_accessors(env)

  if self.page
    if self.page.redirect?
      self.redirect_to(self.page.redirect_url, self.page.redirect_type)
    else
      type = self.page.response_type || 'text/html'
      html = self.render_page

      self.log 'Rendered liquid page template'

      [200, { 'Content-Type' => type }, [html]]
    end
  else
    [404, { 'Content-Type' => 'text/html' }, [self.render_404]]
  end
end