Sha256: e0413e642166216cd4f76d9869f82ea2170deb906d02988f912af755d737efbe

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 KB

Contents

require File.join(File.dirname(__FILE__), 'file_base')
module Mack
  module Rendering # :nodoc:
    module Type # :nodoc:
      # Used to render a template that's relative to a controller.
      # 
      # Example:
      #   class UsersController
      #     include Mack::Controller
      #     # /users/:id
      #     def show
      #       @user = User.first(params[:id])
      #     end
      #     # /users
      #     def index
      #       @users = User.all
      #       render(:action, :list)
      #     end
      #   end
      # When some calls /users/1 the file: app/views/users/show.html.erb will be rendered.
      # When some calls /users the file: app/views/users/list.html.erb will be rendered.
      class Action < Mack::Rendering::Type::FileBase
        
        # See Mack::Rendering::Type::FileBase render_file for more information.
        # 
        # The path to the file is built like such:
        #   app/views/#{controller name}/#{render_value || action name (show, index, etc...)}.#{format (html, xml, js, etc...)}.#{extension defined in the engine}
        # Example:
        #   app/views/users/show.html.erb 
        def render
          a_file = File.join(self.controller_view_path, "#{self._render_value}.#{self._options[:format]}")
          render_file(a_file)
        end
        
      end # Action
    end # Type
  end # Rendering
end # Mack

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mack-0.8.0.100 lib/mack/rendering/type/action.rb
mack-0.8.0.101 lib/mack/rendering/type/action.rb
mack-0.8.1 lib/mack/rendering/type/action.rb
mack-0.8.0.2 lib/mack/rendering/type/action.rb
mack-0.8.2 lib/mack/rendering/type/action.rb
mack-0.8.3 lib/mack/rendering/type/action.rb
mack-0.8.3.1 lib/mack/rendering/type/action.rb