aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-08-07 03:18:45 -0300
committerYehuda Katz <wycats@gmail.com>2009-08-07 03:18:45 -0300
commit0612fd0f09977dece11a0325a0d7ee07c5cab35c (patch)
treed225dd3b608eca95a388f61bda4225de75654a79
parentb3e199f6981b2fbf062fe668ff93b7dc56e98a38 (diff)
downloadrails-0612fd0f09977dece11a0325a0d7ee07c5cab35c.tar.gz
rails-0612fd0f09977dece11a0325a0d7ee07c5cab35c.tar.bz2
rails-0612fd0f09977dece11a0325a0d7ee07c5cab35c.zip
Replace _render_template_with_layout with _render_template since the layout is optional
-rw-r--r--actionmailer/lib/action_mailer/base.rb4
-rw-r--r--actionmailer/test/mail_service_test.rb10
-rw-r--r--actionpack/lib/action_view/render/partials.rb4
-rw-r--r--actionpack/lib/action_view/render/rendering.rb22
-rw-r--r--actionpack/lib/action_view/test_case.rb4
-rw-r--r--actionpack/test/controller/logging_test.rb3
-rw-r--r--actionpack/test/controller/render_test.rb3
7 files changed, 29 insertions, 21 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index b5a0d0ab96..7b03a7f9ff 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -566,7 +566,7 @@ module ActionMailer #:nodoc:
@template = initialize_template_class(body)
layout = _pick_layout(layout, true) unless
ActionController::Base.exempt_from_layout.include?(template.handler)
- @template._render_template_with_layout(template, layout, {})
+ @template._render_template(template, layout, {})
ensure
@current_template_content_type = nil
end
@@ -592,7 +592,7 @@ module ActionMailer #:nodoc:
!template || ActionController::Base.exempt_from_layout.include?(template.handler))
if template
- @template._render_template_with_layout(template, layout, opts)
+ @template._render_template(template, layout, opts)
elsif inline = opts[:inline]
@template._render_inline(inline, layout, opts)
end
diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb
index 30d1b836c4..f2a8c2303c 100644
--- a/actionmailer/test/mail_service_test.rb
+++ b/actionmailer/test/mail_service_test.rb
@@ -573,12 +573,14 @@ class ActionMailerTest < Test::Unit::TestCase
@info_contents, @debug_contents = "", ""
end
- def info(str)
- @info_contents << str
+ def info(str = nil, &blk)
+ @info_contents << str if str
+ @info_contents << blk.call if block_given?
end
- def debug(str)
- @debug_contents << str
+ def debug(str = nil, &blk)
+ @debug_contents << str if str
+ @debug_contents << blk.call if block_given?
end
end
diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb
index 7a791d03ce..98694788f8 100644
--- a/actionpack/lib/action_view/render/partials.rb
+++ b/actionpack/lib/action_view/render/partials.rb
@@ -248,7 +248,7 @@ module ActionView
options[:_template] = template
- _render_template(template, locals)
+ _render_single_template(template, locals)
end
end
@@ -275,7 +275,7 @@ module ActionView
index += 1
- _render_template(template, locals)
+ _render_single_template(template, locals)
end.join(spacer)
end
diff --git a/actionpack/lib/action_view/render/rendering.rb b/actionpack/lib/action_view/render/rendering.rb
index 527cef97c7..911e480d50 100644
--- a/actionpack/lib/action_view/render/rendering.rb
+++ b/actionpack/lib/action_view/render/rendering.rb
@@ -27,7 +27,7 @@ module ActionView
if file = options[:file]
template = find_by_parts(file, {:formats => formats})
- _render_template_with_layout(template, layout, :locals => options[:locals])
+ _render_template(template, layout, :locals => options[:locals])
elsif inline = options[:inline]
_render_inline(inline, layout, options)
elsif text = options[:text]
@@ -54,7 +54,7 @@ module ActionView
old_content, @_content_for[:layout] = @_content_for[:layout], content
@cached_content_for_layout = @_content_for[:layout]
- _render_template(layout, locals)
+ _render_single_template(layout, locals)
ensure
@_content_for[:layout] = old_content
end
@@ -97,9 +97,9 @@ module ActionView
!@_content_for.key?(name) && @_proc_for_layout || @_default_layout
end
- def _render_template(template, local_assigns = {})
+ def _render_single_template(template, locals = {})
with_template(template) do
- template.render(self, local_assigns) do |*names|
+ template.render(self, locals) do |*names|
capture(*names, &layout_proc(names.first))
end
end
@@ -115,7 +115,7 @@ module ActionView
def _render_inline(inline, layout, options)
handler = Template.handler_class_for_extension(options[:type] || "erb")
template = Template.new(options[:inline], "inline #{options[:inline].inspect}", handler, {})
- content = _render_template(template, options[:locals] || {})
+ content = _render_single_template(template, options[:locals] || {})
layout ? _render_content(content, layout, options[:locals]) : content
end
@@ -132,18 +132,22 @@ module ActionView
def render_template(options)
@assigns_added = nil
template, layout, partial = options.values_at(:_template, :_layout, :_partial)
- _render_template_with_layout(template, layout, options, partial)
+ _render_template(template, layout, options, partial)
end
- def _render_template_with_layout(template, layout = nil, options = {}, partial = nil)
- logger && logger.info("Rendering #{template.identifier}#{' (#{options[:status]})' if options[:status]}")
+ def _render_template(template, layout = nil, options = {}, partial = nil)
+ logger && logger.info do
+ msg = "Rendering #{template.identifier}"
+ msg << " (#{options[:status]})" if options[:status]
+ msg
+ end
locals = options[:locals] || {}
content = if partial
_render_partial_object(template, options)
else
- _render_template(template, locals)
+ _render_single_template(template, locals)
end
_render_content(content, layout, locals)
diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb
index 3f3951509a..71a4a88afe 100644
--- a/actionpack/lib/action_view/test_case.rb
+++ b/actionpack/lib/action_view/test_case.rb
@@ -9,8 +9,8 @@ module ActionView
end
attr_internal :rendered
- alias_method :_render_template_without_template_tracking, :_render_template
- def _render_template(template, local_assigns = {})
+ alias_method :_render_template_without_template_tracking, :_render_single_template
+ def _render_single_template(template, local_assigns = {})
if template.respond_to?(:identifier) && template.present?
@_rendered[:partials][template] += 1 if template.partial?
@_rendered[:template] ||= []
diff --git a/actionpack/test/controller/logging_test.rb b/actionpack/test/controller/logging_test.rb
index a7ed1b8665..98ffbc3813 100644
--- a/actionpack/test/controller/logging_test.rb
+++ b/actionpack/test/controller/logging_test.rb
@@ -17,9 +17,10 @@ class LoggingTest < ActionController::TestCase
@level = Logger::DEBUG
end
- def method_missing(method, *args)
+ def method_missing(method, *args, &blk)
@logged ||= []
@logged << args.first
+ @logged << blk.call if block_given?
end
end
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index d0fa67c945..947ffa9ea6 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -17,8 +17,9 @@ class MockLogger
@logged = []
end
- def method_missing(method, *args)
+ def method_missing(method, *args, &blk)
@logged << args.first
+ @logged << blk.call if block_given?
end
end