Class: Mack::Rendering::Action

Inherits:
Base
  • Object
show all
Defined in:
lib/rendering/classes/action.rb

Overview

Used when someone calls render(:action => “index”)

Instance Attribute Summary

Attributes inherited from Base

#options, #view_binder

Instance Method Summary collapse

Methods inherited from Base

#initialize, #params

Constructor Details

This class inherits a constructor from Mack::Rendering::Base

Instance Method Details

#renderObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rendering/classes/action.rb', line 6

def render
  begin
    # Try to render the action:
    return render_file(options[:action], options)
  rescue Errno::ENOENT => e
    begin
      # If the action doesn't exist on disk, try to render it from the public directory:
      t = render_file(options[:action], {:dir => MACK_PUBLIC, :ext => ".#{params(:format)}", :layout => false}.merge(options))
      # Because it's being served from public don't wrap a layout around it!
      # self.controller.instance_variable_get("@render_options").merge!({:layout => false})
      return t
    rescue Errno::ENOENT => ex
    end
    # Raise the original exception because something bad has happened!
    raise e
  end
end