Class: Mack::Rendering::Type::Js
- Defined in:
- lib/mack-javascript/rendering/type/js.rb
Overview
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.
Instance Method Summary collapse
- #allow_layout? ⇒ Boolean
-
#render ⇒ Object
See Mack::Rendering::Type::FileBase render_file for more information.
Instance Method Details
#allow_layout? ⇒ Boolean
30 31 32 |
# File 'lib/mack-javascript/rendering/type/js.rb', line 30 def allow_layout? false end |
#render ⇒ Object
See Mack::Rendering::Type::FileBase render_file for more information.
23 24 25 26 27 28 |
# File 'lib/mack-javascript/rendering/type/js.rb', line 23 def render self.[:format] = "js" 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, :js) end |