Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 3084

Show
Ignore:
Timestamp:
11/18/05 08:32:17 (4 years ago)
Author:
marcel
Message:

Make rjs templates always implicitly skip out on layouts.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r3080 r3084  
    11*SVN* 
     2 
     3* Make rjs templates always implicitly skip out on layouts. [Marcel Molina Jr.] 
    24 
    35* Correct length for the truncate text helper.  #2913 [Stefan Kaes] 
  • trunk/actionpack/lib/action_controller/base.rb

    r3015 r3084  
    638638 
    639639      def render_action(action_name, status = nil, with_layout = true) 
    640         if with_layout 
    641           render_with_layout(default_template_name(action_name), status) 
     640        template = default_template_name(action_name) 
     641        if with_layout && !template_exempt_from_layout?(template)  
     642          render_with_layout(template, status) 
    642643        else 
    643           render_with_no_layout(default_template_name(action_name), status) 
     644          render_without_layout(template, status) 
    644645        end 
    645646      end 
     
    920921      end 
    921922 
     923      def template_exempt_from_layout?(template_name = default_template_name) 
     924        @template.javascript_template_exists?(template_name) 
     925      end 
     926 
    922927      def assert_existance_of_template_file(template_name) 
    923928        unless template_exists?(template_name) || ignore_missing_templates 
  • trunk/actionpack/lib/action_controller/layout.rb

    r2777 r3084  
    230230    private 
    231231      def apply_layout?(template_with_options, options) 
    232         if template_with_options 
    233           (options.has_key?(:layout) && options[:layout]!=false) || options.values_at(:text, :file, :inline, :partial, :nothing).compact.empty? 
    234         else 
    235           true 
    236         end 
     232        template_with_options ?  candidate_for_layout?(options) : !template_exempt_from_layout? 
     233      end 
     234 
     235      def candidate_for_layout?(options) 
     236        (options.has_key?(:layout) && options[:layout] != false) ||  
     237        options.values_at(:text, :file, :inline, :partial, :nothing).compact.empty? && 
     238        !template_exempt_from_layout?(default_template_name(options[:action])) 
    237239      end 
    238240 
  • trunk/actionpack/test/controller/new_render_test.rb

    r3078 r3084  
    193193             "accessing_params_in_template", 
    194194             "accessing_params_in_template_with_layout", 
    195              "render_with_explicit_template" 
     195             "render_with_explicit_template", 
     196             "test_rendering_rjs_action_explicitly" 
    196197          "layouts/standard" 
    197198        when "builder_layout_test"