mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
ActionView: Allow to register a Template handler with a Symbol (dont kill markaby) (closes #4328) [murphy@cYcnus.de]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4056 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
1886de8612
commit
0c07e08d60
2 changed files with 9 additions and 1 deletions
|
@ -168,7 +168,7 @@ module ActionView #:nodoc:
|
|||
@@debug_rjs = false
|
||||
cattr_accessor :debug_rjs
|
||||
|
||||
@@template_handlers = {}
|
||||
@@template_handlers = HashWithIndifferentAccess.new
|
||||
|
||||
module CompiledTemplates #:nodoc:
|
||||
# holds compiled template code
|
||||
|
|
|
@ -15,6 +15,7 @@ end
|
|||
class CustomHandlerTest < Test::Unit::TestCase
|
||||
def setup
|
||||
ActionView::Base.register_template_handler "foo", CustomHandler
|
||||
ActionView::Base.register_template_handler :foo2, CustomHandler
|
||||
@view = ActionView::Base.new
|
||||
end
|
||||
|
||||
|
@ -25,6 +26,13 @@ class CustomHandlerTest < Test::Unit::TestCase
|
|||
result )
|
||||
end
|
||||
|
||||
def test_custom_render2
|
||||
result = @view.render_template( "foo2", "hello <%= one %>", nil, :one => "two" )
|
||||
assert_equal(
|
||||
[ "hello <%= one %>", { :one => "two" }, @view ],
|
||||
result )
|
||||
end
|
||||
|
||||
def test_unhandled_extension
|
||||
# uses the ERb handler by default if the extension isn't recognized
|
||||
result = @view.render_template( "bar", "hello <%= one %>", nil, :one => "two" )
|
||||
|
|
Loading…
Reference in a new issue