From d2ccb852d4e1f6f1b01e43f32213053ae3bef408 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Fri, 18 Jul 2008 16:00:20 -0500 Subject: Removed lagacy TemplateHandler#render API. Left in a legacy TemplateHandler and Compilable stub so plugins will not have to change anything. --- actionpack/test/controller/layout_test.rb | 12 ++---------- actionpack/test/template/render_test.rb | 30 +++++------------------------- 2 files changed, 7 insertions(+), 35 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb index 92b6aa4f2f..72c01a9102 100644 --- a/actionpack/test/controller/layout_test.rb +++ b/actionpack/test/controller/layout_test.rb @@ -31,16 +31,8 @@ end class MultipleExtensions < LayoutTest end -class MabView < ActionView::TemplateHandler - def initialize(view) - end - - def render(template, local_assigns) - template.source - end -end - -ActionView::Template::register_template_handler :mab, MabView +ActionView::Template::register_template_handler :mab, + lambda { |template| template.source.inspect } class LayoutAutoDiscoveryTest < Test::Unit::TestCase def setup diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index cc5b4900dc..b1af043099 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -94,38 +94,18 @@ class ViewRenderTest < Test::Unit::TestCase assert_equal "Hello, World!", @view.render(:inline => "Hello, World!", :type => :foo) end - class CustomHandler < ActionView::TemplateHandler - def render(template, local_assigns) - [template.source, local_assigns].inspect - end - end - - def test_render_inline_with_custom_type - ActionView::Template.register_template_handler :foo, CustomHandler - assert_equal '["Hello, World!", {}]', @view.render(:inline => "Hello, World!", :type => :foo) - end - - def test_render_inline_with_locals_and_custom_type - ActionView::Template.register_template_handler :foo, CustomHandler - assert_equal '["Hello, <%= name %>!", {:name=>"Josh"}]', @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }, :type => :foo) - end - - class CompilableCustomHandler < ActionView::TemplateHandler - include ActionView::TemplateHandlers::Compilable - - def compile(template) - "@output_buffer = ''\n" + - "@output_buffer << 'source: #{template.source.inspect}'\n" - end + CustomHandler = lambda do |template| + "@output_buffer = ''\n" + + "@output_buffer << 'source: #{template.source.inspect}'\n" end def test_render_inline_with_compilable_custom_type - ActionView::Template.register_template_handler :foo, CompilableCustomHandler + ActionView::Template.register_template_handler :foo, CustomHandler assert_equal 'source: "Hello, World!"', @view.render(:inline => "Hello, World!", :type => :foo) end def test_render_inline_with_locals_and_compilable_custom_type - ActionView::Template.register_template_handler :foo, CompilableCustomHandler + ActionView::Template.register_template_handler :foo, CustomHandler assert_equal 'source: "Hello, <%= name %>!"', @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }, :type => :foo) end end -- cgit v1.2.3