Class: Mack::Rendering::Type::Xml
- 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
Instance Method Summary collapse
-
#render ⇒ Object
See Mack::Rendering::Type::FileBase render_file for more information.
Methods inherited from FileBase
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
#render ⇒ Object
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.[:format] = "xml" self.controller.response["Content-Type"] = Mack::Utils::MimeTypes[self.[:format]] x_file = File.join(self.controller_view_path, "#{self._render_value}.#{self.[:format]}") render_file(x_file, :xml) end |