Sha256: 42a4a89d6aa7cc452eb1c17bc5ee1b2c0d1f681cde38c6e95a9921e94029a470

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

module Mack
  module Rendering # :nodoc:
    module Type # :nodoc:
      # Used to render an XML template that's relative to a controller.
      # 
      # Example:
      #   class UsersController < Mack::Controller::Base
      #     # /users/:id
      #     def show
      #       @user = User.first(params(:id))
      #     end
      #     # /users
      #     def index
      #       @users = User.all
      #       render(:xml, :list)
      #     end
      #   end
      # When some calls /users/1.xml the file: app/views/users/show.xml.builder will be rendered.
      # When some calls /users.xml the file: app/views/users/list.xml.builder will be rendered.
      class Js < Mack::Rendering::Type::FileBase
        
        # See Mack::Rendering::Type::FileBase render_file for more information.
        def render
          self._options[:format] = "js"
          self.controller.response["Content-Type"] = Mack::Utils::MimeTypes[self._options[:format]]
          x_file = File.join(self.controller_view_path, "#{self._render_value}.#{self._options[:format]}")
          render_file(x_file, :js)
        end
        
        def allow_layout?
          false
        end
        
      end # Xml
    end # Type
  end # Rendering
end # Mack

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mack-javascript-0.8.3.1 lib/mack-javascript/rendering/type/js.rb
mack-javascript-0.8.2 lib/mack-javascript/rendering/type/js.rb
mack-javascript-0.8.3 lib/mack-javascript/rendering/type/js.rb