Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
34b21804
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,发现更多精彩内容 >>
提交
34b21804
编写于
3月 08, 2010
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More refactoring. Split _normalize_args and _normalize_options concerns.
上级
4bae77a8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
12 deletion
+27
-12
actionpack/lib/abstract_controller/layouts.rb
actionpack/lib/abstract_controller/layouts.rb
+6
-2
actionpack/lib/abstract_controller/rendering.rb
actionpack/lib/abstract_controller/rendering.rb
+8
-4
actionpack/lib/action_controller/metal/rendering.rb
actionpack/lib/action_controller/metal/rendering.rb
+13
-6
未找到文件。
actionpack/lib/abstract_controller/layouts.rb
浏览文件 @
34b21804
...
...
@@ -277,8 +277,8 @@ def _layout
end
end
def
render_to_body
(
options
=
{}
)
if
(
options
.
keys
&
[
:text
,
:inline
,
:partial
]).
empty?
||
options
.
key?
(
:layout
)
def
render_to_body
(
options
)
if
_include_layout?
(
options
)
layout
=
options
.
key?
(
:layout
)
?
options
[
:layout
]
:
:default
value
=
_layout_for_option
(
layout
)
...
...
@@ -344,6 +344,10 @@ def _default_layout(require_layout = false)
layout_name
end
def
_include_layout?
(
options
)
(
options
.
keys
&
[
:text
,
:inline
,
:partial
]).
empty?
||
options
.
key?
(
:layout
)
end
def
_action_has_layout?
true
end
...
...
actionpack/lib/abstract_controller/rendering.rb
浏览文件 @
34b21804
...
...
@@ -45,7 +45,8 @@ def view_context
# Mostly abstracts the fact that calling render twice is a DoubleRenderError.
# Delegates render_to_body and sticks the result in self.response_body.
def
render
(
*
args
,
&
block
)
options
=
_normalize_options
(
*
args
,
&
block
)
options
=
_normalize_args
(
*
args
,
&
block
)
_normalize_options
(
options
)
self
.
response_body
=
render_to_body
(
options
)
end
...
...
@@ -70,8 +71,8 @@ def render_to_body(options = {})
# render_to_body into a String.
#
# :api: plugin
def
render_to_string
(
*
args
)
options
=
_normalize_options
(
*
arg
s
)
def
render_to_string
(
options
=
{}
)
_normalize_options
(
option
s
)
AbstractController
::
Rendering
.
body_to_s
(
render_to_body
(
options
))
end
...
...
@@ -131,7 +132,7 @@ def self.body_to_s(body)
# Normalize options, by converting render "foo" to render :template => "prefix/foo"
# and render "/foo" to render :file => "/foo".
def
_normalize_
option
s
(
action
=
nil
,
options
=
{})
def
_normalize_
arg
s
(
action
=
nil
,
options
=
{})
case
action
when
Hash
options
,
action
=
action
,
nil
...
...
@@ -151,6 +152,9 @@ def _normalize_options(action=nil, options={})
options
end
def
_normalize_options
(
options
)
end
# Take in a set of options and determine the template to render
#
# ==== Options
...
...
actionpack/lib/action_controller/metal/rendering.rb
浏览文件 @
34b21804
...
...
@@ -18,6 +18,11 @@ def render(*args)
response_body
end
def
render_to_body
(
options
)
_process_options
(
options
)
super
end
private
def
_render_partial
(
options
)
...
...
@@ -30,7 +35,7 @@ def format_for_text
formats
.
first
end
def
_normalize_
option
s
(
action
=
nil
,
options
=
{},
&
blk
)
def
_normalize_
arg
s
(
action
=
nil
,
options
=
{},
&
blk
)
case
action
when
NilClass
when
Hash
...
...
@@ -38,9 +43,14 @@ def _normalize_options(action=nil, options={}, &blk)
when
String
,
Symbol
options
=
super
else
options
.
merge!
:partial
=>
action
options
.
merge!
(
:partial
=>
action
)
end
options
[
:update
]
=
blk
if
block_given?
options
end
def
_normalize_options
(
options
)
if
options
.
key?
(
:text
)
&&
options
[
:text
].
respond_to?
(
:to_text
)
options
[
:text
]
=
options
[
:text
].
to_text
end
...
...
@@ -49,10 +59,7 @@ def _normalize_options(action=nil, options={}, &blk)
options
[
:status
]
=
Rack
::
Utils
.
status_code
(
options
[
:status
])
end
options
[
:update
]
=
blk
if
block_given?
_process_options
(
options
)
options
super
end
def
_process_options
(
options
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录