Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved TemplateHandlers to Base

  • Loading branch information...
commit 42d215a925a228778e43f7040f03ad8f3eb5341c 1 parent 75e04b5
Joshua Peek josh authored
1  actionpack/lib/action_view/base.rb
View
@@ -151,6 +151,7 @@ class MissingTemplate < ActionViewError #: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
2  actionpack/lib/action_view/helpers/cache_helper.rb
View
@@ -32,7 +32,7 @@ module CacheHelper
# <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
2  actionpack/lib/action_view/inline_template.rb
View
@@ -7,7 +7,7 @@ def initialize(view, source, locals = {}, type = nil)
@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
7 actionpack/lib/action_view/template.rb
View
@@ -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 @@ def initialize(view, path, use_full_path = nil, locals = {})
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
2  actionpack/test/controller/layout_test.rb
View
@@ -40,7 +40,7 @@ def render(template)
end
end
-ActionView::Template::register_template_handler :mab, MabView
+ActionView::Base.register_template_handler :mab, MabView
class LayoutAutoDiscoveryTest < Test::Unit::TestCase
def setup
8 actionpack/test/template/render_test.rb
View
@@ -101,12 +101,12 @@ def render(template)
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 @@ def compile(template)
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
Please sign in to comment.
Something went wrong with that request. Please try again.