Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
c86424a7
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,体验更适合开发者的 AI 搜索 >>
提交
c86424a7
编写于
12月 25, 2009
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Break instrumentation into several end-points so rendering of partials can be optimized.
上级
48273a44
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
30 deletion
+42
-30
actionpack/lib/action_view/render/partials.rb
actionpack/lib/action_view/render/partials.rb
+23
-19
actionpack/lib/action_view/render/rendering.rb
actionpack/lib/action_view/render/rendering.rb
+17
-7
actionpack/lib/action_view/template.rb
actionpack/lib/action_view/template.rb
+2
-4
未找到文件。
actionpack/lib/action_view/render/partials.rb
浏览文件 @
c86424a7
...
...
@@ -205,11 +205,22 @@ def setup(options, block)
end
def
render
options
=
@options
if
@collection
=
collection
render_collection
ActiveSupport
::
Notifications
.
instrument
(
:render_collection
,
:path
=>
@path
,
:count
=>
@collection
.
size
)
do
render_collection
end
else
@template
=
template
=
find_template
render_template
(
template
,
@object
||
@locals
[
template
.
variable_name
])
content
=
ActiveSupport
::
Notifications
.
instrument
(
:render_partial
,
:path
=>
@path
)
do
render_partial
end
if
!
@block
&&
options
[
:layout
]
content
=
@view
.
_render_layout
(
find_template
(
options
[
:layout
]),
@locals
){
content
}
end
content
end
end
...
...
@@ -227,9 +238,7 @@ def render_collection
end
def
collection_with_template
(
template
)
options
=
@options
segments
,
locals
,
as
=
[],
@locals
,
options
[
:as
]
||
template
.
variable_name
segments
,
locals
,
as
=
[],
@locals
,
@options
[
:as
]
||
template
.
variable_name
counter_name
=
template
.
counter_name
locals
[
counter_name
]
=
-
1
...
...
@@ -246,9 +255,7 @@ def collection_with_template(template)
end
def
collection_without_template
options
=
@options
segments
,
locals
,
as
=
[],
@locals
,
options
[
:as
]
segments
,
locals
,
as
=
[],
@locals
,
@options
[
:as
]
index
,
template
=
-
1
,
nil
@collection
.
each
do
|
object
|
...
...
@@ -263,18 +270,15 @@ def collection_without_template
segments
end
def
render_
template
(
template
,
object
=
@object
)
options
,
locals
,
view
=
@options
,
@locals
,
@view
locals
[
options
[
:as
]
||
template
.
variable_name
]
=
object
def
render_
partial
(
object
=
@object
)
@template
=
template
=
find_template
locals
,
view
=
@locals
,
@view
content
=
template
.
render
(
view
,
locals
)
do
|*
name
|
@view
.
_layout_for
(
*
name
,
&
@block
)
end
object
||=
locals
[
template
.
variable_name
]
locals
[
@options
[
:as
]
||
template
.
variable_name
]
=
object
if
@block
||
!
options
[
:layout
]
content
else
@view
.
_render_layout
(
find_template
(
options
[
:layout
]),
@locals
){
content
}
template
.
render
(
view
,
locals
)
do
|*
name
|
view
.
_layout_for
(
*
name
,
&
@block
)
end
end
...
...
actionpack/lib/action_view/render/rendering.rb
浏览文件 @
c86424a7
...
...
@@ -77,16 +77,19 @@ def _layout_for(name = nil, &block)
end
def
_render_inline
(
inline
,
layout
,
options
)
handler
=
Template
.
handler_class_for_extension
(
options
[
:type
]
||
"erb"
)
template
=
Template
.
new
(
options
[
:inline
],
"inline template"
,
handler
,
{})
locals
=
options
[
:locals
]
locals
=
options
[
:locals
]
content
=
template
.
render
(
self
,
locals
)
content
=
ActiveSupport
::
Notifications
.
instrument
(
:render_inline
)
do
handler
=
Template
.
handler_class_for_extension
(
options
[
:type
]
||
"erb"
)
template
=
Template
.
new
(
options
[
:inline
],
"inline template"
,
handler
,
{})
template
.
render
(
self
,
locals
)
end
_render_text
(
content
,
layout
,
locals
)
end
def
_render_text
(
content
,
layout
,
locals
)
ActiveSupport
::
Notifications
.
instrument
(
:render_text
)
content
=
_render_layout
(
layout
,
locals
){
content
}
if
layout
content
end
...
...
@@ -110,8 +113,13 @@ def _render_template(template, layout = nil, options = {}, partial = nil)
msg
end
locals
=
options
[
:locals
]
||
{}
content
=
partial
?
_render_partial_object
(
template
,
options
)
:
template
.
render
(
self
,
locals
)
locals
=
options
[
:locals
]
||
{}
content
=
ActiveSupport
::
Notifications
.
instrument
(
:render_template
,
:identifier
=>
template
.
identifier
,
:layout
=>
(
layout
?
layout
.
identifier
:
nil
))
do
partial
?
_render_partial_object
(
template
,
options
)
:
template
.
render
(
self
,
locals
)
end
@_content_for
[
:layout
]
=
content
if
layout
...
...
@@ -124,7 +132,9 @@ def _render_template(template, layout = nil, options = {}, partial = nil)
end
def
_render_layout
(
layout
,
locals
,
&
block
)
layout
.
render
(
self
,
locals
){
|*
name
|
_layout_for
(
*
name
,
&
block
)
}
ActiveSupport
::
Notifications
.
instrument
(
:render_layout
,
:identifier
=>
layout
.
identifier
)
do
layout
.
render
(
self
,
locals
){
|*
name
|
_layout_for
(
*
name
,
&
block
)
}
end
end
end
end
actionpack/lib/action_view/template.rb
浏览文件 @
c86424a7
...
...
@@ -36,10 +36,8 @@ def initialize(source, identifier, handler, details)
end
def
render
(
view
,
locals
,
&
block
)
ActiveSupport
::
Notifications
.
instrument
(
:render_template
,
:identifier
=>
identifier
)
do
method_name
=
compile
(
locals
,
view
)
view
.
send
(
method_name
,
locals
,
&
block
)
end
method_name
=
compile
(
locals
,
view
)
view
.
send
(
method_name
,
locals
,
&
block
)
rescue
Exception
=>
e
if
e
.
is_a?
(
Template
::
Error
)
e
.
sub_template_of
(
self
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录