Changeset 8471
- Timestamp:
- 12/21/07 12:30:29 (5 months ago)
- Files:
-
- trunk/actionpack/lib/action_controller/layout.rb (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/layout.rb
r8378 r8471 30 30 # // The header part of this layout 31 31 # <%= yield %> 32 # // The footer part of this layout -->32 # // The footer part of this layout 33 33 # 34 34 # And then you have content pages that look like this: … … 36 36 # hello world 37 37 # 38 # Not a word about common structures. At rendering time, the content page is computed and then inserted in the layout, 39 # like this: 38 # At rendering time, the content page is computed and then inserted in the layout, like this: 40 39 # 41 40 # // The header part of this layout 42 41 # hello world 43 # // The footer part of this layout --> 42 # // The footer part of this layout 43 # 44 # NOTE: The old notation for rendering the view from a layout was to expose the magic <tt>@content_for_layout</tt> instance 45 # variable. The preferred notation now is to use <tt>yield</tt>, as documented above. 44 46 # 45 47 # == Accessing shared variables … … 125 127 # layout "weblog_standard" 126 128 # 127 # If no directory is specified for the template name, the template will by default be looked for in +app/views/layouts/+.129 # If no directory is specified for the template name, the template will by default be looked for in <tt>app/views/layouts/</tt>. 128 130 # Otherwise, it will be looked up relative to the template root. 129 131 # … … 150 152 # 151 153 # If most of your actions use the same layout, it makes perfect sense to define a controller-wide layout as described above. 152 # Some times you'll have exceptions, though, where one action wants to use a different layout than the rest of the controller. 153 # This is possible using the <tt>render</tt> method. It's just a bit more manual work as you'll have to supply fully 154 # qualified template and layout names as this example shows: 155 # 156 # class WeblogController < ActionController::Base 154 # Sometimes you'll have exceptions where one action wants to use a different layout than the rest of the controller. 155 # You can do this by passing a <tt>:layout</tt> option to the <tt>render</tt> call. For example: 156 # 157 # class WeblogController < ActionController::Base 158 # layout "weblog_standard" 159 # 157 160 # def help 158 # render :action => "help /index", :layout => "help"161 # render :action => "help", :layout => "help" 159 162 # end 160 163 # end 161 164 # 162 # As you can see, you pass the template as the first parameter, the status code as the second ("200" is OK), and the layout 163 # as the third. 164 # 165 # NOTE: The old notation for rendering the view from a layout was to expose the magic <tt>@content_for_layout</tt> instance 166 # variable. The preferred notation now is to use <tt>yield</tt>, as documented above. 165 # This will render the help action with the "help" layout instead of the controller-wide "weblog_standard" layout. 167 166 module ClassMethods 168 # If a layout is specified, all rendered actions will have their result rendered 167 # If a layout is specified, all rendered actions will have their result rendered 169 168 # when the layout <tt>yield</tt>s. This layout can itself depend on instance variables assigned during action 170 169 # performance and have access to them as any normal template would.