Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d8f352e9
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,发现更多精彩内容 >>
提交
d8f352e9
编写于
6月 17, 2009
作者:
Y
Yehuda Katz + Carl Lerche
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename ActionView::Template::Path ActionView::Resolver
上级
7ac9f290
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
165 addition
and
203 deletion
+165
-203
actionpack/lib/action_view.rb
actionpack/lib/action_view.rb
+14
-14
actionpack/lib/action_view/paths.rb
actionpack/lib/action_view/paths.rb
+1
-1
actionpack/lib/action_view/template/path.rb
actionpack/lib/action_view/template/path.rb
+124
-125
actionpack/test/abstract_controller/layouts_test.rb
actionpack/test/abstract_controller/layouts_test.rb
+1
-1
actionpack/test/lib/fixture_template.rb
actionpack/test/lib/fixture_template.rb
+1
-38
actionpack/test/new_base/content_type_test.rb
actionpack/test/new_base/content_type_test.rb
+1
-1
actionpack/test/new_base/etag_test.rb
actionpack/test/new_base/etag_test.rb
+1
-1
actionpack/test/new_base/render_action_test.rb
actionpack/test/new_base/render_action_test.rb
+4
-4
actionpack/test/new_base/render_implicit_action_test.rb
actionpack/test/new_base/render_implicit_action_test.rb
+1
-1
actionpack/test/new_base/render_layout_test.rb
actionpack/test/new_base/render_layout_test.rb
+3
-3
actionpack/test/new_base/render_partial_test.rb
actionpack/test/new_base/render_partial_test.rb
+1
-1
actionpack/test/new_base/render_rjs_test.rb
actionpack/test/new_base/render_rjs_test.rb
+1
-1
actionpack/test/new_base/render_template_test.rb
actionpack/test/new_base/render_template_test.rb
+3
-3
actionpack/test/new_base/render_test.rb
actionpack/test/new_base/render_test.rb
+1
-1
actionpack/test/new_base/render_text_test.rb
actionpack/test/new_base/render_text_test.rb
+2
-2
actionpack/test/new_base/render_xml_test.rb
actionpack/test/new_base/render_xml_test.rb
+1
-1
actionpack/test/template/compiled_templates_test.rb
actionpack/test/template/compiled_templates_test.rb
+1
-1
actionpack/test/template/render_test.rb
actionpack/test/template/render_test.rb
+3
-3
railties/lib/initializer.rb
railties/lib/initializer.rb
+1
-1
未找到文件。
actionpack/lib/action_view.rb
浏览文件 @
d8f352e9
...
...
@@ -33,21 +33,21 @@ def self.load_all!
[
Base
,
InlineTemplate
,
TemplateError
]
end
autoload
:Base
,
'action_view/base'
autoload
:Helpers
,
'action_view/helpers'
autoload
:InlineTemplate
,
'action_view/template/inline'
autoload
:Partials
,
'action_view/render/partials'
autoload
:
Path
,
'action_view/template/path'
autoload
:PathSet
,
'action_view/paths'
autoload
:Rendering
,
'action_view/render/rendering'
autoload
:Renderable
,
'action_view/template/renderable'
autoload
:Base
,
'action_view/base'
autoload
:Helpers
,
'action_view/helpers'
autoload
:InlineTemplate
,
'action_view/template/inline'
autoload
:Partials
,
'action_view/render/partials'
autoload
:
Resolver
,
'action_view/template/path'
autoload
:PathSet
,
'action_view/paths'
autoload
:Rendering
,
'action_view/render/rendering'
autoload
:Renderable
,
'action_view/template/renderable'
autoload
:RenderablePartial
,
'action_view/template/partial'
autoload
:Template
,
'action_view/template/template'
autoload
:TemplateError
,
'action_view/template/error'
autoload
:TemplateHandler
,
'action_view/template/handler'
autoload
:TemplateHandlers
,
'action_view/template/handlers'
autoload
:TextTemplate
,
'action_view/template/text'
autoload
:Helpers
,
'action_view/helpers'
autoload
:Template
,
'action_view/template/template'
autoload
:TemplateError
,
'action_view/template/error'
autoload
:TemplateHandler
,
'action_view/template/handler'
autoload
:TemplateHandlers
,
'action_view/template/handlers'
autoload
:TextTemplate
,
'action_view/template/text'
autoload
:Helpers
,
'action_view/helpers'
end
class
ERB
...
...
actionpack/lib/action_view/paths.rb
浏览文件 @
d8f352e9
...
...
@@ -3,7 +3,7 @@ class PathSet < Array #:nodoc:
def
self
.
type_cast
(
obj
)
if
obj
.
is_a?
(
String
)
cache
=
!
defined?
(
Rails
)
||
!
Rails
.
respond_to?
(
:configuration
)
||
Rails
.
configuration
.
cache_classes
Template
::
FileSystemPath
WithFallback
.
new
(
obj
,
:cache
=>
cache
)
FileSystemResolver
WithFallback
.
new
(
obj
,
:cache
=>
cache
)
else
obj
end
...
...
actionpack/lib/action_view/template/path.rb
浏览文件 @
d8f352e9
require
"pathname"
require
"action_view/template/template"
module
ActionView
class
Template
# Abstract super class
class
Path
def
initialize
(
options
)
@cache
=
options
[
:cache
]
@cached
=
{}
end
# Normalizes the arguments and passes it on to find_template
def
find_by_parts
(
*
args
)
find_all_by_parts
(
*
args
).
first
end
def
find_all_by_parts
(
name
,
details
=
{},
prefix
=
nil
,
partial
=
nil
)
details
[
:locales
]
=
[
I18n
.
locale
]
name
=
name
.
to_s
.
gsub
(
handler_matcher
,
''
).
split
(
"/"
)
find_templates
(
name
.
pop
,
details
,
[
prefix
,
*
name
].
compact
.
join
(
"/"
),
partial
)
end
# Abstract superclass
class
Resolver
def
initialize
(
options
)
@cache
=
options
[
:cache
]
@cached
=
{}
end
# Normalizes the arguments and passes it on to find_template
def
find_by_parts
(
*
args
)
find_all_by_parts
(
*
args
).
first
end
private
# This is what child classes implement. No defaults are needed
# because Path guarentees that the arguments are present and
# normalized.
def
find_templates
(
name
,
details
,
prefix
,
partial
)
raise
NotImplementedError
end
def
valid_handlers
@valid_handlers
||=
TemplateHandlers
.
extensions
end
def
handler_matcher
@handler_matcher
||=
begin
e
=
valid_handlers
.
join
(
'|'
)
/\.(?:
#{
e
}
)$/
end
end
def
handler_glob
e
=
TemplateHandlers
.
extensions
.
map
{
|
h
|
".
#{
h
}
,"
}.
join
"{
#{
e
}
}"
end
def
formats_glob
@formats_glob
||=
begin
'{'
+
Mime
::
SET
.
symbols
.
map
{
|
l
|
".
#{
l
}
,"
}.
join
+
'}'
end
end
def
cached
(
key
)
return
yield
unless
@cache
return
@cached
[
key
]
if
@cached
.
key?
(
key
)
@cached
[
key
]
=
yield
end
def
find_all_by_parts
(
name
,
details
=
{},
prefix
=
nil
,
partial
=
nil
)
details
[
:locales
]
=
[
I18n
.
locale
]
name
=
name
.
to_s
.
gsub
(
handler_matcher
,
''
).
split
(
"/"
)
find_templates
(
name
.
pop
,
details
,
[
prefix
,
*
name
].
compact
.
join
(
"/"
),
partial
)
end
class
FileSystemPath
<
Path
private
# This is what child classes implement. No defaults are needed
# because Resolver guarantees that the arguments are present and
# normalized.
def
find_templates
(
name
,
details
,
prefix
,
partial
)
raise
NotImplementedError
end
def
initialize
(
path
,
options
=
{})
raise
ArgumentError
,
"path already is a Path class"
if
path
.
is_a?
(
Path
)
super
(
options
)
@path
=
Pathname
.
new
(
path
).
expand_path
def
valid_handlers
@valid_handlers
||=
TemplateHandlers
.
extensions
end
def
handler_matcher
@handler_matcher
||=
begin
e
=
valid_handlers
.
join
(
'|'
)
/\.(?:
#{
e
}
)$/
end
end
# TODO: This is the currently needed API. Make this suck less
# ==== <suck>
attr_reader
:path
def
handler_glob
e
=
TemplateHandlers
.
extensions
.
map
{
|
h
|
".
#{
h
}
,"
}.
join
"{
#{
e
}
}"
end
def
to_s
path
.
to_s
def
formats_glob
@formats_glob
||=
begin
'{'
+
Mime
::
SET
.
symbols
.
map
{
|
l
|
".
#{
l
}
,"
}.
join
+
'}'
end
end
def
to_str
path
.
to_s
end
def
cached
(
key
)
return
yield
unless
@cache
return
@cached
[
key
]
if
@cached
.
key?
(
key
)
@cached
[
key
]
=
yield
end
end
def
==
(
path
)
to_str
==
path
.
to_str
end
class
FileSystemResolver
<
Resolver
def
eql?
(
path
)
to_str
==
path
.
to_str
end
# ==== </suck>
def
find_templates
(
name
,
details
,
prefix
,
partial
,
root
=
"
#{
@path
}
/"
)
if
glob
=
details_to_glob
(
name
,
details
,
prefix
,
partial
,
root
)
cached
(
glob
)
do
Dir
[
glob
].
map
do
|
path
|
next
if
File
.
directory?
(
path
)
source
=
File
.
read
(
path
)
identifier
=
Pathname
.
new
(
path
).
expand_path
.
to_s
Template
.
new
(
source
,
identifier
,
*
path_to_details
(
path
))
end
.
compact
end
def
initialize
(
path
,
options
=
{})
raise
ArgumentError
,
"path already is a Resolver class"
if
path
.
is_a?
(
Resolver
)
super
(
options
)
@path
=
Pathname
.
new
(
path
).
expand_path
end
# TODO: This is the currently needed API. Make this suck less
# ==== <suck>
attr_reader
:path
def
to_s
path
.
to_s
end
def
to_str
path
.
to_s
end
def
==
(
path
)
to_str
==
path
.
to_str
end
def
eql?
(
path
)
to_str
==
path
.
to_str
end
# ==== </suck>
def
find_templates
(
name
,
details
,
prefix
,
partial
,
root
=
"
#{
@path
}
/"
)
if
glob
=
details_to_glob
(
name
,
details
,
prefix
,
partial
,
root
)
cached
(
glob
)
do
Dir
[
glob
].
map
do
|
path
|
next
if
File
.
directory?
(
path
)
source
=
File
.
read
(
path
)
identifier
=
Pathname
.
new
(
path
).
expand_path
.
to_s
Template
.
new
(
source
,
identifier
,
*
path_to_details
(
path
))
end
.
compact
end
end
private
end
# :api: plugin
def
details_to_glob
(
name
,
details
,
prefix
,
partial
,
root
)
path
=
""
path
<<
"
#{
prefix
}
/"
unless
prefix
.
empty?
path
<<
(
partial
?
"_
#{
name
}
"
:
name
)
extensions
=
""
[
:locales
,
:formats
].
each
do
|
k
|
extensions
<<
if
exts
=
details
[
k
]
'{'
+
exts
.
map
{
|
e
|
".
#{
e
}
,"
}.
join
+
'}'
else
k
==
:formats
?
formats_glob
:
''
end
private
# :api: plugin
def
details_to_glob
(
name
,
details
,
prefix
,
partial
,
root
)
path
=
""
path
<<
"
#{
prefix
}
/"
unless
prefix
.
empty?
path
<<
(
partial
?
"_
#{
name
}
"
:
name
)
extensions
=
""
[
:locales
,
:formats
].
each
do
|
k
|
extensions
<<
if
exts
=
details
[
k
]
'{'
+
exts
.
map
{
|
e
|
".
#{
e
}
,"
}.
join
+
'}'
else
k
==
:formats
?
formats_glob
:
''
end
"
#{
root
}#{
path
}#{
extensions
}#{
handler_glob
}
"
end
# TODO: fix me
# :api: plugin
def
path_to_details
(
path
)
# [:erb, :format => :html, :locale => :en, :partial => true/false]
if
m
=
path
.
match
(
%r'/(_)?[
\w
-]+(
\.
[
\w
-]+)*
\.
(
\w
+)$'
)
partial
=
m
[
1
]
==
'_'
details
=
(
m
[
2
]
||
""
).
split
(
'.'
).
reject
{
|
e
|
e
.
empty?
}
handler
=
Template
.
handler_class_for_extension
(
m
[
3
])
format
=
Mime
[
details
.
last
]
&&
details
.
pop
.
to_sym
locale
=
details
.
last
&&
details
.
pop
.
to_sym
return
handler
,
:format
=>
format
,
:locale
=>
locale
,
:partial
=>
partial
end
end
"
#{
root
}#{
path
}#{
extensions
}#{
handler_glob
}
"
end
class
FileSystemPathWithFallback
<
FileSystemPath
def
find_templates
(
name
,
details
,
prefix
,
partial
)
templates
=
super
return
super
(
name
,
details
,
prefix
,
partial
,
''
)
if
templates
.
empty?
templates
# TODO: fix me
# :api: plugin
def
path_to_details
(
path
)
# [:erb, :format => :html, :locale => :en, :partial => true/false]
if
m
=
path
.
match
(
%r'/(_)?[
\w
-]+(
\.
[
\w
-]+)*
\.
(
\w
+)$'
)
partial
=
m
[
1
]
==
'_'
details
=
(
m
[
2
]
||
""
).
split
(
'.'
).
reject
{
|
e
|
e
.
empty?
}
handler
=
Template
.
handler_class_for_extension
(
m
[
3
])
format
=
Mime
[
details
.
last
]
&&
details
.
pop
.
to_sym
locale
=
details
.
last
&&
details
.
pop
.
to_sym
return
handler
,
:format
=>
format
,
:locale
=>
locale
,
:partial
=>
partial
end
end
end
class
FileSystemResolverWithFallback
<
FileSystemResolver
def
find_templates
(
name
,
details
,
prefix
,
partial
)
templates
=
super
return
super
(
name
,
details
,
prefix
,
partial
,
''
)
if
templates
.
empty?
templates
end
end
end
\ No newline at end of file
actionpack/test/abstract_controller/layouts_test.rb
浏览文件 @
d8f352e9
...
...
@@ -9,7 +9,7 @@ class Base < AbstractController::Base
include
AbstractController
::
Renderer
include
AbstractController
::
Layouts
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"layouts/hello.erb"
=>
"With String <%= yield %>"
,
"layouts/hello_override.erb"
=>
"With Override <%= yield %>"
,
"layouts/abstract_controller_tests/layouts/with_string_implied_child.erb"
=>
...
...
actionpack/test/lib/fixture_template.rb
浏览文件 @
d8f352e9
module
ActionView
#:nodoc:
class
Template
class
FixturePath
<
Path
class
FixtureResolver
<
Resolver
def
initialize
(
hash
=
{},
options
=
{})
super
(
options
)
@hash
=
hash
...
...
@@ -65,40 +64,4 @@ def path_to_details(path)
end
end
end
# class FixtureTemplate < Template
# class FixturePath < Template::Path
# def initialize(hash = {})
# @hash = {}
#
# hash.each do |k, v|
# @hash[k.sub(/\.\w+$/, '')] = FixtureTemplate.new(v, k.split("/").last, self)
# end
#
# super("fixtures://root")
# end
#
# def find_template(path)
# @hash[path]
# end
# end
#
# def initialize(body, *args)
# @body = body
# super(*args)
# end
#
# def source
# @body
# end
#
# private
#
# def find_full_path(path, load_paths)
# return '/', path
# end
#
# end
end
end
\ No newline at end of file
actionpack/test/new_base/content_type_test.rb
浏览文件 @
d8f352e9
...
...
@@ -19,7 +19,7 @@ def set_on_render
class
ImpliedController
<
ActionController
::
Base
# Template's mime type is used if no content_type is specified
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"content_type/implied/i_am_html_erb.html.erb"
=>
"Hello world!"
,
"content_type/implied/i_am_xml_erb.xml.erb"
=>
"<xml>Hello world!</xml>"
,
"content_type/implied/i_am_html_builder.html.builder"
=>
"xml.p 'Hello'"
,
...
...
actionpack/test/new_base/etag_test.rb
浏览文件 @
d8f352e9
...
...
@@ -2,7 +2,7 @@
module
Etags
class
BasicController
<
ActionController
::
Base
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"etags/basic/base.html.erb"
=>
"Hello from without_layout.html.erb"
,
"layouts/etags.html.erb"
=>
"teh <%= yield %> tagz"
)]
...
...
actionpack/test/new_base/render_action_test.rb
浏览文件 @
d8f352e9
...
...
@@ -3,7 +3,7 @@
module
RenderAction
# This has no layout and it works
class
BasicController
<
ActionController
::
Base
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"render_action/basic/hello_world.html.erb"
=>
"Hello world!"
)]
...
...
@@ -117,7 +117,7 @@ module RenderActionWithApplicationLayout
# # ==== Render actions with layouts ====
class
BasicController
<
::
ApplicationController
# Set the view path to an application view structure with layouts
self
.
view_paths
=
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"render_action_with_application_layout/basic/hello_world.html.erb"
=>
"Hello World!"
,
"render_action_with_application_layout/basic/hello.html.builder"
=>
"xml.p 'Omg'"
,
"layouts/application.html.erb"
=>
"OHAI <%= yield %> KTHXBAI"
,
...
...
@@ -202,7 +202,7 @@ class TestLayout < SimpleRouteCase
module
RenderActionWithControllerLayout
class
BasicController
<
ActionController
::
Base
self
.
view_paths
=
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"render_action_with_controller_layout/basic/hello_world.html.erb"
=>
"Hello World!"
,
"layouts/render_action_with_controller_layout/basic.html.erb"
=>
"With Controller Layout! <%= yield %> KTHXBAI"
)]
...
...
@@ -263,7 +263,7 @@ class ControllerLayoutTest < SimpleRouteCase
module
RenderActionWithBothLayouts
class
BasicController
<
ActionController
::
Base
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
({
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
({
"render_action_with_both_layouts/basic/hello_world.html.erb"
=>
"Hello World!"
,
"layouts/application.html.erb"
=>
"OHAI <%= yield %> KTHXBAI"
,
"layouts/render_action_with_both_layouts/basic.html.erb"
=>
"With Controller Layout! <%= yield %> KTHXBAI"
...
...
actionpack/test/new_base/render_implicit_action_test.rb
浏览文件 @
d8f352e9
...
...
@@ -2,7 +2,7 @@
module
RenderImplicitAction
class
SimpleController
<
::
ApplicationController
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"render_implicit_action/simple/hello_world.html.erb"
=>
"Hello world!"
,
"render_implicit_action/simple/hyphen-ated.html.erb"
=>
"Hello hyphen-ated!"
)]
...
...
actionpack/test/new_base/render_layout_test.rb
浏览文件 @
d8f352e9
...
...
@@ -2,7 +2,7 @@
module
ControllerLayouts
class
ImplicitController
<
::
ApplicationController
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"layouts/application.html.erb"
=>
"OMG <%= yield %> KTHXBAI"
,
"layouts/override.html.erb"
=>
"Override! <%= yield %>"
,
"basic.html.erb"
=>
"Hello world!"
,
...
...
@@ -26,7 +26,7 @@ def builder_override
end
class
ImplicitNameController
<
::
ApplicationController
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"layouts/controller_layouts/implicit_name.html.erb"
=>
"OMGIMPLICIT <%= yield %> KTHXBAI"
,
"basic.html.erb"
=>
"Hello world!"
)]
...
...
@@ -68,7 +68,7 @@ class LayoutOptionsTest < SimpleRouteCase
end
class
MismatchFormatController
<
::
ApplicationController
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"layouts/application.html.erb"
=>
"<html><%= yield %></html>"
,
"controller_layouts/mismatch_format/index.js.rjs"
=>
"page[:test].omg"
,
"controller_layouts/mismatch_format/implicit.rjs"
=>
"page[:test].omg"
...
...
actionpack/test/new_base/render_partial_test.rb
浏览文件 @
d8f352e9
...
...
@@ -4,7 +4,7 @@ module RenderPartial
class
BasicController
<
ActionController
::
Base
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"render_partial/basic/_basic.html.erb"
=>
"OMG!"
,
"render_partial/basic/basic.html.erb"
=>
"<%= @test_unchanged = 'goodbye' %><%= render :partial => 'basic' %><%= @test_unchanged %>"
)]
...
...
actionpack/test/new_base/render_rjs_test.rb
浏览文件 @
d8f352e9
...
...
@@ -4,7 +4,7 @@ module RenderRjs
class
BasicController
<
ActionController
::
Base
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"render_rjs/basic/index.js.rjs"
=>
"page[:customer].replace_html render(:partial => 'customer')"
,
"render_rjs/basic/index_html.js.rjs"
=>
"page[:customer].replace_html :partial => 'customer'"
,
"render_rjs/basic/_customer.js.erb"
=>
"JS Partial"
,
...
...
actionpack/test/new_base/render_template_test.rb
浏览文件 @
d8f352e9
...
...
@@ -3,7 +3,7 @@
module
RenderTemplate
class
WithoutLayoutController
<
ActionController
::
Base
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"test/basic.html.erb"
=>
"Hello from basic.html.erb"
,
"shared.html.erb"
=>
"Elastica"
,
"locals.html.erb"
=>
"The secret is <%= secret %>"
,
...
...
@@ -79,7 +79,7 @@ class TestWithoutLayout < SimpleRouteCase
end
class
WithLayoutController
<
::
ApplicationController
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"test/basic.html.erb"
=>
"Hello from basic.html.erb"
,
"shared.html.erb"
=>
"Elastica"
,
"layouts/application.html.erb"
=>
"<%= yield %>, I'm here!"
,
...
...
@@ -148,7 +148,7 @@ class TestWithLayout < SimpleRouteCase
module
Compatibility
class
WithoutLayoutController
<
ActionController
::
Base
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"test/basic.html.erb"
=>
"Hello from basic.html.erb"
,
"shared.html.erb"
=>
"Elastica"
)]
...
...
actionpack/test/new_base/render_test.rb
浏览文件 @
d8f352e9
...
...
@@ -2,7 +2,7 @@
module
Render
class
BlankRenderController
<
ActionController
::
Base
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"render/blank_render/index.html.erb"
=>
"Hello world!"
,
"render/blank_render/access_request.html.erb"
=>
"The request: <%= request.method.to_s.upcase %>"
,
"render/blank_render/access_action_name.html.erb"
=>
"Action Name: <%= action_name %>"
,
...
...
actionpack/test/new_base/render_text_test.rb
浏览文件 @
d8f352e9
...
...
@@ -2,7 +2,7 @@
module
RenderText
class
SimpleController
<
ActionController
::
Base
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
]
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
]
def
index
render
:text
=>
"hello david"
...
...
@@ -10,7 +10,7 @@ def index
end
class
WithLayoutController
<
::
ApplicationController
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"layouts/application.html.erb"
=>
"<%= yield %>, I'm here!"
,
"layouts/greetings.html.erb"
=>
"<%= yield %>, I wish thee well."
,
"layouts/ivar.html.erb"
=>
"<%= yield %>, <%= @ivar %>"
...
...
actionpack/test/new_base/render_xml_test.rb
浏览文件 @
d8f352e9
...
...
@@ -4,7 +4,7 @@ module RenderXml
# This has no layout and it works
class
BasicController
<
ActionController
::
Base
self
.
view_paths
=
[
ActionView
::
Template
::
FixturePath
.
new
(
self
.
view_paths
=
[
ActionView
::
FixtureResolver
.
new
(
"render_xml/basic/with_render_erb"
=>
"Hello world!"
)]
end
...
...
actionpack/test/template/compiled_templates_test.rb
浏览文件 @
d8f352e9
...
...
@@ -41,7 +41,7 @@ def render_with_cache(*args)
end
def
render_without_cache
(
*
args
)
path
=
ActionView
::
Template
::
FileSystemPath
WithFallback
.
new
(
FIXTURE_LOAD_PATH
)
path
=
ActionView
::
FileSystemResolver
WithFallback
.
new
(
FIXTURE_LOAD_PATH
)
view_paths
=
ActionView
::
Base
.
process_view_paths
(
path
)
ActionView
::
Base
.
new
(
view_paths
,
{}).
render
(
*
args
)
end
...
...
actionpack/test/template/render_test.rb
浏览文件 @
d8f352e9
...
...
@@ -255,7 +255,7 @@ class CachedViewRenderTest < ActiveSupport::TestCase
# Ensure view path cache is primed
def
setup
view_paths
=
ActionController
::
Base
.
view_paths
assert_equal
ActionView
::
Template
::
FileSystemPath
WithFallback
,
view_paths
.
first
.
class
assert_equal
ActionView
::
FileSystemResolver
WithFallback
,
view_paths
.
first
.
class
setup_view
(
view_paths
)
end
end
...
...
@@ -266,9 +266,9 @@ class LazyViewRenderTest < ActiveSupport::TestCase
# Test the same thing as above, but make sure the view path
# is not eager loaded
def
setup
path
=
ActionView
::
Template
::
FileSystemPath
WithFallback
.
new
(
FIXTURE_LOAD_PATH
)
path
=
ActionView
::
FileSystemResolver
WithFallback
.
new
(
FIXTURE_LOAD_PATH
)
view_paths
=
ActionView
::
Base
.
process_view_paths
(
path
)
assert_equal
ActionView
::
Template
::
FileSystemPath
WithFallback
,
view_paths
.
first
.
class
assert_equal
ActionView
::
FileSystemResolver
WithFallback
,
view_paths
.
first
.
class
setup_view
(
view_paths
)
end
end
railties/lib/initializer.rb
浏览文件 @
d8f352e9
...
...
@@ -401,7 +401,7 @@ def load_observers
def
load_view_paths
if
configuration
.
frameworks
.
include?
(
:action_view
)
if
configuration
.
cache_classes
view_path
=
ActionView
::
Template
::
FileSystemPath
.
new
(
configuration
.
view_path
)
view_path
=
ActionView
::
FileSystemResolverWithFallback
.
new
(
configuration
.
view_path
)
ActionController
::
Base
.
view_paths
=
view_path
if
configuration
.
frameworks
.
include?
(
:action_controller
)
ActionMailer
::
Base
.
template_root
=
view_path
if
configuration
.
frameworks
.
include?
(
:action_mailer
)
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录