Sha256: 48b1c22d47afbbf669a4c8a7c6e4f2a4726753203d58293842c41ebe710d47e0

Contents?: true

Size: 1.22 KB

Versions: 7

Compression:

Stored size: 1.22 KB

Contents

require File.join(File.dirname(__FILE__), 'file_base')
module Mack
  module Rendering # :nodoc:
    module Type # :nodoc:
      # Used to render an XML 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(: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 Xml < Mack::Rendering::Type::FileBase
        
        # See Mack::Rendering::Type::FileBase render_file for more information.
        def render
          self._options[:format] = "xml"
          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, :xml)
        end
        
      end # Xml
    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/xml.rb
mack-0.8.0.101 lib/mack/rendering/type/xml.rb
mack-0.8.2 lib/mack/rendering/type/xml.rb
mack-0.8.1 lib/mack/rendering/type/xml.rb
mack-0.8.0.2 lib/mack/rendering/type/xml.rb
mack-0.8.3 lib/mack/rendering/type/xml.rb
mack-0.8.3.1 lib/mack/rendering/type/xml.rb