aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-07-03 12:48:00 -0500
committerJoshua Peek <josh@joshpeek.com>2008-07-03 12:48:00 -0500
commit42d215a925a228778e43f7040f03ad8f3eb5341c (patch)
tree3fc10bd3dcad49eeb04ab70128fb1c062f5ca0de /actionpack
parent75e04b52956512d554c83e0134a81c980c15b4fa (diff)
downloadrails-42d215a925a228778e43f7040f03ad8f3eb5341c.tar.gz
rails-42d215a925a228778e43f7040f03ad8f3eb5341c.tar.bz2
rails-42d215a925a228778e43f7040f03ad8f3eb5341c.zip
Moved TemplateHandlers to Base
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/base.rb1
-rw-r--r--actionpack/lib/action_view/helpers/cache_helper.rb2
-rw-r--r--actionpack/lib/action_view/inline_template.rb2
-rw-r--r--actionpack/lib/action_view/template.rb7
-rw-r--r--actionpack/test/controller/layout_test.rb2
-rw-r--r--actionpack/test/template/render_test.rb8
6 files changed, 13 insertions, 9 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index e8e690abec..169bee1bfc 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -151,6 +151,7 @@ module ActionView #:nodoc:
#
# See the ActionView::Helpers::PrototypeHelper::GeneratorMethods documentation for more details.
class Base
+ extend TemplateHandlers
include ERB::Util
attr_accessor :base_path, :assigns, :template_extension, :first_render
diff --git a/actionpack/lib/action_view/helpers/cache_helper.rb b/actionpack/lib/action_view/helpers/cache_helper.rb
index 930c397785..c2aab5aa72 100644
--- a/actionpack/lib/action_view/helpers/cache_helper.rb
+++ b/actionpack/lib/action_view/helpers/cache_helper.rb
@@ -32,7 +32,7 @@ module ActionView
# <i>Topics listed alphabetically</i>
# <% end %>
def cache(name = {}, options = nil, &block)
- handler = Template.handler_class_for_extension(current_render_extension.to_sym)
+ handler = Base.handler_class_for_extension(current_render_extension.to_sym)
handler.new(@controller).cache_fragment(block, name, options)
end
end
diff --git a/actionpack/lib/action_view/inline_template.rb b/actionpack/lib/action_view/inline_template.rb
index fd0ad48302..3a97f47e32 100644
--- a/actionpack/lib/action_view/inline_template.rb
+++ b/actionpack/lib/action_view/inline_template.rb
@@ -7,7 +7,7 @@ module ActionView #:nodoc:
@extension = type
@locals = locals || {}
- @handler = self.class.handler_class_for_extension(@extension).new(@view)
+ @handler = Base.handler_class_for_extension(@extension).new(@view)
end
def method_key
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index 0cba1942f7..d4118f0f86 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionpack/lib/action_view/template.rb
@@ -1,6 +1,9 @@
module ActionView #:nodoc:
class Template #:nodoc:
- extend TemplateHandlers
+ class << self
+ # TODO: Deprecate
+ delegate :register_template_handler, :to => 'ActionView::Base'
+ end
attr_accessor :locals
attr_reader :handler, :path, :extension, :filename, :method
@@ -20,7 +23,7 @@ module ActionView #:nodoc:
set_extension_and_file_name
@locals = locals || {}
- @handler = self.class.handler_class_for_extension(@extension).new(@view)
+ @handler = Base.handler_class_for_extension(@extension).new(@view)
end
def render_template
diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb
index 3dc311b78a..52ab72bb99 100644
--- a/actionpack/test/controller/layout_test.rb
+++ b/actionpack/test/controller/layout_test.rb
@@ -40,7 +40,7 @@ class MabView < ActionView::TemplateHandler
end
end
-ActionView::Template::register_template_handler :mab, MabView
+ActionView::Base.register_template_handler :mab, MabView
class LayoutAutoDiscoveryTest < Test::Unit::TestCase
def setup
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb
index 726cf37026..0dcf88da83 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionpack/test/template/render_test.rb
@@ -101,12 +101,12 @@ class ViewRenderTest < Test::Unit::TestCase
end
def test_render_inline_with_custom_type
- ActionView::Template.register_template_handler :foo, CustomHandler
+ ActionView::Base.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
+ ActionView::Base.register_template_handler :foo, CustomHandler
assert_equal '["Hello, <%= name %>!", {:name=>"Josh"}]', @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }, :type => :foo)
end
@@ -121,12 +121,12 @@ class ViewRenderTest < Test::Unit::TestCase
end
def test_render_inline_with_compilable_custom_type
- ActionView::Template.register_template_handler :foo, CompilableCustomHandler
+ ActionView::Base.register_template_handler :foo, CompilableCustomHandler
assert_equal 'locals: {}, 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::Base.register_template_handler :foo, CompilableCustomHandler
assert_equal 'locals: {:name=>"Josh"}, source: "Hello, <%= name %>!"', @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }, :type => :foo)
end
end