Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
9dfae153
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,发现更多精彩内容 >>
未验证
提交
9dfae153
编写于
4月 08, 2020
作者:
R
Rafael França
提交者:
GitHub
4月 08, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #38900 from joelhawksley/annotations-html-only
`ActionView::Base.annotate_template_file_names` only annotates HTML
上级
46cb94f6
3b28486e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
5 deletion
+18
-5
actionview/lib/action_view/template/handlers/erb.rb
actionview/lib/action_view/template/handlers/erb.rb
+1
-0
actionview/lib/action_view/template/handlers/erb/erubi.rb
actionview/lib/action_view/template/handlers/erb/erubi.rb
+2
-1
actionview/test/actionpack/controller/render_test.rb
actionview/test/actionpack/controller/render_test.rb
+15
-4
未找到文件。
actionview/lib/action_view/template/handlers/erb.rb
浏览文件 @
9dfae153
...
...
@@ -59,6 +59,7 @@ def call(template, source)
erb
,
escape:
(
self
.
class
.
escape_ignore_list
.
include?
template
.
type
),
trim:
(
self
.
class
.
erb_trim_mode
==
"-"
),
format:
template
.
format
,
short_identifier:
template
.
short_identifier
).
src
end
...
...
actionview/lib/action_view/template/handlers/erb/erubi.rb
浏览文件 @
9dfae153
...
...
@@ -14,7 +14,8 @@ def initialize(input, properties = {})
# Dup properties so that we don't modify argument
properties
=
Hash
[
properties
]
if
ActionView
::
Base
.
annotate_template_file_names
# Annotate output with template file names, if we're rendering HTML
if
ActionView
::
Base
.
annotate_template_file_names
&&
properties
[
:format
]
==
:html
properties
[
:preamble
]
=
"@output_buffer.safe_append='<!-- BEGIN
#{
properties
[
:short_identifier
]
}
-->
\n
';"
properties
[
:postamble
]
=
"@output_buffer.safe_append='<!-- END
#{
properties
[
:short_identifier
]
}
-->
\n
';@output_buffer.to_s"
else
...
...
actionview/test/actionpack/controller/render_test.rb
浏览文件 @
9dfae153
...
...
@@ -1457,17 +1457,28 @@ def test_render_call_to_partial_with_layout_in_main_layout_and_within_content_fo
def
test_template_annotations
ActionView
::
Base
.
annotate_template_file_names
=
true
get
:
render_with_explicit_template_with_locals
get
:
greeting
lines
=
@response
.
body
.
split
(
"
\n
"
)
assert_includes
lines
.
first
,
"<!-- BEGIN"
assert_includes
lines
.
first
,
"test/fixtures/actionpack/test/
render_file_with_locals
.erb -->"
assert_includes
lines
.
first
,
"test/fixtures/actionpack/test/
greeting.html
.erb -->"
assert_includes
lines
[
1
],
"Th
e secret is area51
"
assert_includes
lines
[
1
],
"Th
is is grand!
"
assert_includes
lines
.
last
,
"<!-- END"
assert_includes
lines
.
last
,
"test/fixtures/actionpack/test/render_file_with_locals.erb -->"
assert_includes
lines
.
last
,
"test/fixtures/actionpack/test/greeting.html.erb -->"
ensure
ActionView
::
Base
.
annotate_template_file_names
=
false
end
def
test_template_annotations_do_not_render_for_non_html_format
ActionView
::
Base
.
annotate_template_file_names
=
true
get
:render_with_explicit_template_with_locals
assert_not_includes
@response
.
body
,
"BEGIN"
assert_equal
@response
.
body
.
split
(
"
\n
"
).
length
,
1
ensure
ActionView
::
Base
.
annotate_template_file_names
=
false
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录