Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
6f03c314
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,发现更多精彩内容 >>
未验证
提交
6f03c314
编写于
3月 19, 2019
作者:
A
Aaron Patterson
提交者:
GitHub
3月 19, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #35662 from jhawthorn/fallback_resolver_no_virtual_path
Remove virtual_path from fallback templates
上级
7180fa7b
d0c745b8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
8 deletion
+32
-8
actionview/lib/action_view/template/resolver.rb
actionview/lib/action_view/template/resolver.rb
+16
-8
actionview/test/template/fallback_file_system_resolver_test.rb
...nview/test/template/fallback_file_system_resolver_test.rb
+16
-0
未找到文件。
actionview/lib/action_view/template/resolver.rb
浏览文件 @
6f03c314
...
...
@@ -184,17 +184,21 @@ def query(path, details, formats, outside_app_allowed, locals)
template_paths
=
reject_files_external_to_app
(
template_paths
)
unless
outside_app_allowed
template_paths
.
map
do
|
template
|
handler
,
format
,
variant
=
extract_handler_and_format_and_variant
(
template
)
FileTemplate
.
new
(
File
.
expand_path
(
template
),
handler
,
virtual_path:
path
.
virtual
,
format:
format
,
variant:
variant
,
locals:
locals
)
build_template
(
template
,
path
.
virtual
,
locals
)
end
end
def
build_template
(
template
,
virtual_path
,
locals
)
handler
,
format
,
variant
=
extract_handler_and_format_and_variant
(
template
)
FileTemplate
.
new
(
File
.
expand_path
(
template
),
handler
,
virtual_path:
virtual_path
,
format:
format
,
variant:
variant
,
locals:
locals
)
end
def
reject_files_external_to_app
(
files
)
files
.
reject
{
|
filename
|
!
inside_path?
(
@path
,
filename
)
}
end
...
...
@@ -385,5 +389,9 @@ class FallbackFileSystemResolver < FileSystemResolver #:nodoc:
def
self
.
instances
[
new
(
""
),
new
(
"/"
)]
end
def
build_template
(
template
,
virtual_path
,
locals
)
super
(
template
,
nil
,
locals
)
end
end
end
actionview/test/template/fallback_file_system_resolver_test.rb
0 → 100644
浏览文件 @
6f03c314
# frozen_string_literal: true
require
"abstract_unit"
class
FallbackFileSystemResolverTest
<
ActiveSupport
::
TestCase
def
setup
@root_resolver
=
ActionView
::
FallbackFileSystemResolver
.
new
(
"/"
)
end
def
test_should_have_no_virtual_path
templates
=
@root_resolver
.
find_all
(
"hello_world.erb"
,
"
#{
FIXTURE_LOAD_PATH
}
/test"
,
false
,
locale:
[],
formats:
[
:html
],
variants:
[],
handlers:
[
:erb
])
assert_equal
1
,
templates
.
size
assert_equal
"Hello world!"
,
templates
[
0
].
source
assert_nil
templates
[
0
].
virtual_path
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录