| Class | Mack::Rendering::Type::Action |
| In: |
lib/mack/rendering/type/action.rb
|
| Parent: | Mack::Rendering::Type::FileBase |
Used to render a 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(:action, :list)
end
end
When some calls /users/1 the file: app/views/users/show.html.erb will be rendered. When some calls /users the file: app/views/users/list.html.erb will be rendered.
See Mack::Rendering::Type::FileBase render_file for more information.
The path to the file is built like such:
app/views/#{controller name}/#{render_value || action name (show, index, etc...)}.#{format (html, xml, js, etc...)}.#{extension defined in the engine}
Example:
app/views/users/show.html.erb
# File lib/mack/rendering/type/action.rb, line 30
30: def render
31: a_file = File.join(self.controller_view_path, "#{self._render_value}.#{self._options[:format]}")
32: render_file(a_file)
33: end