Module: ActionController::Layout
- Defined in:
- lib/action_controller/layout.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#active_layout(passed_layout = nil) ⇒ Object
Returns the name of the active layout.
-
#render_with_layout(template_name = default_template_name, status = nil, layout = nil) ⇒ Object
:nodoc:.
Class Method Details
.append_features(base) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/action_controller/layout.rb', line 3 def self.append_features(base) super base.class_eval do alias_method :render_without_layout, :render alias_method :render, :render_with_layout class << self alias_method :inherited_without_layout, :inherited end end base.extend(ClassMethods) end |
Instance Method Details
#active_layout(passed_layout = nil) ⇒ Object
Returns the name of the active layout. If the layout was specified as a method reference (through a symbol), this method is called and the return value is used. Likewise if the layout was specified as an inline method (through a proc or method object). If the layout was defined without a directory, layouts is assumed. So layout "weblog/standard"
will return weblog/standard, but layout "standard"
will return layouts/standard.
194 195 196 197 198 199 200 201 202 |
# File 'lib/action_controller/layout.rb', line 194 def active_layout(passed_layout = nil) layout = passed_layout || self.class.read_inheritable_attribute("layout") active_layout = case layout when Symbol then send(layout) when Proc then layout.call(self) when String then layout end active_layout.include?("/") ? active_layout : "layouts/#{active_layout}" if active_layout end |
#render_with_layout(template_name = default_template_name, status = nil, layout = nil) ⇒ Object
:nodoc:
204 205 206 207 208 209 210 211 212 213 |
# File 'lib/action_controller/layout.rb', line 204 def render_with_layout(template_name = default_template_name, status = nil, layout = nil) #:nodoc: if layout ||= active_layout and action_has_layout? add_variables_to_assigns logger.info("Rendering #{template_name} within #{layout}") unless logger.nil? @content_for_layout = @template.render_file(template_name, true) render_without_layout(layout, status) else render_without_layout(template_name, status) end end |