Class: Mack::Rendering::Type::Xml

Inherits:
FileBase show all
Defined in:
lib/mack/rendering/type/xml.rb

Overview

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.

Instance Attribute Summary

Attributes inherited from Base

#view_template

Instance Method Summary collapse

Methods inherited from FileBase

#concat, #render_file

Methods inherited from Base

#allow_layout?, #capture, #controller_view_path, #find_engine, #find_file, #initialize, #method_missing

Constructor Details

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Mack::Rendering::Type::Base

Instance Method Details

#renderObject

See Mack::Rendering::Type::FileBase render_file for more information.



25
26
27
28
29
30
# File 'lib/mack/rendering/type/xml.rb', line 25

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