Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
bc4d05b2
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bc4d05b2
编写于
11月 23, 2008
作者:
J
Joshua Peek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A back support for legacy TemplateHandler#render API
上级
2c01f2b4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
6 deletion
+38
-6
actionpack/lib/action_view/template_handler.rb
actionpack/lib/action_view/template_handler.rb
+27
-2
actionpack/lib/action_view/template_handlers.rb
actionpack/lib/action_view/template_handlers.rb
+0
-4
actionpack/test/template/render_test.rb
actionpack/test/template/render_test.rb
+11
-0
未找到文件。
actionpack/lib/action_view/template_handler.rb
浏览文件 @
bc4d05b2
# Legacy TemplateHandler stub
module
ActionView
module
TemplateHandlers
#:nodoc:
module
Compilable
def
self
.
included
(
base
)
base
.
extend
(
ClassMethods
)
end
module
ClassMethods
def
call
(
template
)
new
.
compile
(
template
)
end
end
def
compile
(
template
)
raise
"Need to implement
#{
self
.
class
.
name
}
#compile(template)"
end
end
end
class
TemplateHandler
def
self
.
call
(
template
)
new
.
compile
(
template
)
"
#{
name
}
.new(self).render(template, local_assigns)"
end
def
initialize
(
view
=
nil
)
@view
=
view
end
def
render
(
template
,
local_assigns
)
raise
"Need to implement
#{
self
.
class
.
name
}
#render(template, local_assigns)"
end
end
end
actionpack/lib/action_view/template_handlers.rb
浏览文件 @
bc4d05b2
...
...
@@ -4,10 +4,6 @@ module TemplateHandlers #:nodoc:
autoload
:RJS
,
'action_view/template_handlers/rjs'
autoload
:Builder
,
'action_view/template_handlers/builder'
# Legacy Compilable stub
module
Compilable
end
def
self
.
extended
(
base
)
base
.
register_default_template_handler
:erb
,
TemplateHandlers
::
ERB
base
.
register_template_handler
:rjs
,
TemplateHandlers
::
RJS
...
...
actionpack/test/template/render_test.rb
浏览文件 @
bc4d05b2
...
...
@@ -175,6 +175,17 @@ def test_render_inline_with_locals_and_compilable_custom_type
assert_equal
'source: "Hello, <%= name %>!"'
,
@view
.
render
(
:inline
=>
"Hello, <%= name %>!"
,
:locals
=>
{
:name
=>
"Josh"
},
:type
=>
:foo
)
end
class
LegacyHandler
<
ActionView
::
TemplateHandler
def
render
(
template
,
local_assigns
)
"source:
#{
template
.
source
}
; locals:
#{
local_assigns
.
inspect
}
"
end
end
def
test_render_legacy_handler_with_custom_type
ActionView
::
Template
.
register_template_handler
:foo
,
LegacyHandler
assert_equal
'source: Hello, <%= name %>!; locals: {:name=>"Josh"}'
,
@view
.
render
(
:inline
=>
"Hello, <%= name %>!"
,
:locals
=>
{
:name
=>
"Josh"
},
:type
=>
:foo
)
end
def
test_render_with_layout
assert_equal
%(<title></title>\nHello world!\n)
,
@view
.
render
(
:file
=>
"test/hello_world.erb"
,
:layout
=>
"layouts/yield"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录