Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
67a6725b
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,发现更多精彩内容 >>
提交
67a6725b
编写于
3月 08, 2010
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move ViewPaths module to its own file.
上级
68cda695
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
71 addition
and
70 deletion
+71
-70
actionpack/lib/abstract_controller.rb
actionpack/lib/abstract_controller.rb
+1
-0
actionpack/lib/abstract_controller/rendering.rb
actionpack/lib/abstract_controller/rendering.rb
+1
-70
actionpack/lib/abstract_controller/view_paths.rb
actionpack/lib/abstract_controller/view_paths.rb
+69
-0
未找到文件。
actionpack/lib/abstract_controller.rb
浏览文件 @
67a6725b
...
...
@@ -19,4 +19,5 @@ module AbstractController
autoload
:Logger
autoload
:Rendering
autoload
:Translation
autoload
:ViewPaths
end
actionpack/lib/abstract_controller/rendering.rb
浏览文件 @
67a6725b
require
"abstract_controller/base"
require
"active_support/core_ext/array/wrap"
module
AbstractController
class
DoubleRenderError
<
Error
...
...
@@ -10,74 +9,6 @@ def initialize(message = nil)
end
end
module
ViewPaths
extend
ActiveSupport
::
Concern
included
do
class_attribute
:_view_paths
self
.
_view_paths
=
ActionView
::
PathSet
.
new
end
delegate
:find_template
,
:template_exists?
,
:view_paths
,
:formats
,
:formats
=
,
:to
=>
:lookup_context
# LookupContext is the object responsible to hold all information required to lookup
# templates, i.e. view paths and details. Check ActionView::LookupContext for more
# information.
def
lookup_context
@lookup_context
||=
ActionView
::
LookupContext
.
new
(
self
.
class
.
_view_paths
,
details_for_lookup
)
end
def
details_for_lookup
{
}
end
def
append_view_path
(
path
)
lookup_context
.
view_paths
.
push
(
*
path
)
end
def
prepend_view_path
(
path
)
lookup_context
.
view_paths
.
unshift
(
*
path
)
end
module
ClassMethods
# Append a path to the list of view paths for this controller.
#
# ==== Parameters
# path<String, ViewPath>:: If a String is provided, it gets converted into
# the default view path. You may also provide a custom view path
# (see ActionView::ViewPathSet for more information)
def
append_view_path
(
path
)
self
.
view_paths
=
view_paths
.
dup
+
Array
(
path
)
end
# Prepend a path to the list of view paths for this controller.
#
# ==== Parameters
# path<String, ViewPath>:: If a String is provided, it gets converted into
# the default view path. You may also provide a custom view path
# (see ActionView::ViewPathSet for more information)
def
prepend_view_path
(
path
)
self
.
view_paths
=
Array
(
path
)
+
view_paths
.
dup
end
# A list of all of the default view paths for this controller.
def
view_paths
_view_paths
end
# Set the view paths.
#
# ==== Parameters
# paths<ViewPathSet, Object>:: If a ViewPathSet is provided, use that;
# otherwise, process the parameter into a ViewPathSet.
def
view_paths
=
(
paths
)
self
.
_view_paths
=
paths
.
is_a?
(
ActionView
::
PathSet
)
?
paths
:
ActionView
::
Base
.
process_view_paths
(
paths
)
self
.
_view_paths
.
freeze
end
end
end
module
Rendering
extend
ActiveSupport
::
Concern
include
AbstractController
::
ViewPaths
...
...
@@ -166,7 +97,7 @@ def _normalize_options(options)
end
if
(
options
.
keys
&
[
:partial
,
:file
,
:template
]).
empty?
options
[
:_prefix
]
||=
_prefix
options
[
:_prefix
]
||=
_prefix
end
options
[
:template
]
||=
(
options
[
:action
]
||
action_name
).
to_s
...
...
actionpack/lib/abstract_controller/view_paths.rb
0 → 100644
浏览文件 @
67a6725b
module
AbstractController
module
ViewPaths
extend
ActiveSupport
::
Concern
included
do
class_attribute
:_view_paths
self
.
_view_paths
=
ActionView
::
PathSet
.
new
end
delegate
:find_template
,
:template_exists?
,
:view_paths
,
:formats
,
:formats
=
,
:to
=>
:lookup_context
# LookupContext is the object responsible to hold all information required to lookup
# templates, i.e. view paths and details. Check ActionView::LookupContext for more
# information.
def
lookup_context
@lookup_context
||=
ActionView
::
LookupContext
.
new
(
self
.
class
.
_view_paths
,
details_for_lookup
)
end
def
details_for_lookup
{
}
end
def
append_view_path
(
path
)
lookup_context
.
view_paths
.
push
(
*
path
)
end
def
prepend_view_path
(
path
)
lookup_context
.
view_paths
.
unshift
(
*
path
)
end
module
ClassMethods
# Append a path to the list of view paths for this controller.
#
# ==== Parameters
# path<String, ViewPath>:: If a String is provided, it gets converted into
# the default view path. You may also provide a custom view path
# (see ActionView::ViewPathSet for more information)
def
append_view_path
(
path
)
self
.
view_paths
=
view_paths
.
dup
+
Array
(
path
)
end
# Prepend a path to the list of view paths for this controller.
#
# ==== Parameters
# path<String, ViewPath>:: If a String is provided, it gets converted into
# the default view path. You may also provide a custom view path
# (see ActionView::ViewPathSet for more information)
def
prepend_view_path
(
path
)
self
.
view_paths
=
Array
(
path
)
+
view_paths
.
dup
end
# A list of all of the default view paths for this controller.
def
view_paths
_view_paths
end
# Set the view paths.
#
# ==== Parameters
# paths<ViewPathSet, Object>:: If a ViewPathSet is provided, use that;
# otherwise, process the parameter into a ViewPathSet.
def
view_paths
=
(
paths
)
self
.
_view_paths
=
paths
.
is_a?
(
ActionView
::
PathSet
)
?
paths
:
ActionView
::
Base
.
process_view_paths
(
paths
)
self
.
_view_paths
.
freeze
end
end
end
end
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录