Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
4ad5aa9a
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 搜索 >>
提交
4ad5aa9a
编写于
10月 28, 2008
作者:
R
Ryan Bates
提交者:
Joshua Peek
10月 28, 2008
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ensure @content_for_* is checked before yielding to block in render :layout [#8994 state:resolved]
Signed-off-by:
N
Joshua Peek
<
josh@joshpeek.com
>
上级
4684e76a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
16 addition
and
1 deletion
+16
-1
actionpack/lib/action_view/renderable.rb
actionpack/lib/action_view/renderable.rb
+1
-1
actionpack/test/fixtures/layouts/_column.html.erb
actionpack/test/fixtures/layouts/_column.html.erb
+2
-0
actionpack/test/fixtures/test/nested_layout.erb
actionpack/test/fixtures/test/nested_layout.erb
+3
-0
actionpack/test/template/render_test.rb
actionpack/test/template/render_test.rb
+10
-0
未找到文件。
actionpack/lib/action_view/renderable.rb
浏览文件 @
4ad5aa9a
...
...
@@ -36,7 +36,7 @@ def render(view, local_assigns = {})
result
=
view
.
send
(
method_name
(
local_assigns
),
local_assigns
)
do
|*
names
|
ivar
=
:@_proc_for_layout
if
view
.
instance_variable_defined?
(
ivar
)
and
proc
=
view
.
instance_variable_get
(
ivar
)
if
!
view
.
instance_variable_defined?
(
:"@content_for_
#{
names
.
first
}
"
)
&&
view
.
instance_variable_defined?
(
ivar
)
&&
(
proc
=
view
.
instance_variable_get
(
ivar
)
)
view
.
capture
(
*
names
,
&
proc
)
elsif
view
.
instance_variable_defined?
(
ivar
=
:"@content_for_
#{
names
.
first
||
:layout
}
"
)
view
.
instance_variable_get
(
ivar
)
...
...
actionpack/test/fixtures/layouts/_column.html.erb
0 → 100644
浏览文件 @
4ad5aa9a
<div
id=
"column"
>
<%=
yield
:column
%>
</div>
<div
id=
"content"
>
<%=
yield
%>
</div>
\ No newline at end of file
actionpack/test/fixtures/test/nested_layout.erb
0 → 100644
浏览文件 @
4ad5aa9a
<%
content_for
:title
,
"title"
-%>
<%
content_for
:column
do
-%>
column
<%
end
-%>
<%
render
:layout
=>
'layouts/column'
do
-%>
content
<%
end
-%>
\ No newline at end of file
actionpack/test/template/render_test.rb
浏览文件 @
4ad5aa9a
...
...
@@ -162,4 +162,14 @@ def test_render_inline_with_locals_and_compilable_custom_type
ActionView
::
Template
.
register_template_handler
:foo
,
CustomHandler
assert_equal
'source: "Hello, <%= name %>!"'
,
@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"
)
end
def
test_render_with_nested_layout
assert_equal
%(<title>title</title>\n<div id="column">column</div>\n<div id="content">content</div>\n)
,
@view
.
render
(
:file
=>
"test/nested_layout.erb"
,
:layout
=>
"layouts/yield"
)
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录