Module: HighCarb::ViewsController

Included in:
RackApp
Defined in:
lib/highcarb/views_controller.rb

Defined Under Namespace

Classes: ViewContext

Constant Summary collapse

DefaultViewsPath =
Pathname.new(File.expand_path("../../../resources/views/", __FILE__))

Instance Method Summary collapse

Instance Method Details

#render_view(view_name) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/highcarb/views_controller.rb', line 27

def render_view(view_name)
  view_path = root.join("views", view_name + ".haml")
  if not view_path.exist?
    view_path = DefaultViewsPath.join(view_name + ".haml")
  end

  if not view_path.exist?
    not_found! view_name + " view"
  end

  output = Haml::Engine.new(view_path.read).render(ViewContext.new(self, command.options, view_path.dirname))

  throw :response, [200, {'Content-Type' => 'text/html'}, output]
end