Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
e350c4d6
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,体验更适合开发者的 AI 搜索 >>
提交
e350c4d6
编写于
7月 15, 2019
作者:
G
Gannon McGibbon
提交者:
Eugene Kenny
12月 21, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge pull request #36532 from itsWill/add_to_a_to_annotated_source_code
Empty array instead of nil for source_extract
上级
c7bef8aa
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
12 deletion
+29
-12
actionview/CHANGELOG.md
actionview/CHANGELOG.md
+5
-0
actionview/lib/action_view/template/error.rb
actionview/lib/action_view/template/error.rb
+8
-12
actionview/test/template/template_error_test.rb
actionview/test/template/template_error_test.rb
+16
-0
未找到文件。
actionview/CHANGELOG.md
浏览文件 @
e350c4d6
*
annotated_source_code returns an empty array so TemplateErrors without a
template in the backtrace are surfaced properly by DebugExceptions.
*Guilherme Mansur*, *Kasper Timm Hansen*
*
Add autoload for SyntaxErrorInTemplate so syntax errors are correctly raised by DebugExceptions.
*Guilherme Mansur*, *Gannon McGibbon*
...
...
actionview/lib/action_view/template/error.rb
浏览文件 @
e350c4d6
...
...
@@ -81,8 +81,8 @@ def sub_template_message
end
end
def
source_extract
(
indentation
=
0
,
output
=
:console
)
return
unless
num
=
line_number
def
source_extract
(
indentation
=
0
)
return
[]
unless
num
=
line_number
num
=
num
.
to_i
source_code
=
@template
.
source
.
split
(
"
\n
"
)
...
...
@@ -91,9 +91,9 @@ def source_extract(indentation = 0, output = :console)
end_on_line
=
[
num
+
SOURCE_CODE_RADIUS
-
1
,
source_code
.
length
].
min
indent
=
end_on_line
.
to_s
.
size
+
indentation
return
unless
source_code
=
source_code
[
start_on_line
..
end_on_line
]
return
[]
unless
source_code
=
source_code
[
start_on_line
..
end_on_line
]
formatted_code_for
(
source_code
,
start_on_line
,
indent
,
output
)
formatted_code_for
(
source_code
,
start_on_line
,
indent
)
end
def
sub_template_of
(
template_path
)
...
...
@@ -122,15 +122,11 @@ def source_location
end
+
file_name
end
def
formatted_code_for
(
source_code
,
line_counter
,
indent
,
output
)
start_value
=
(
output
==
:html
)
?
{}
:
[]
source_code
.
inject
(
start_value
)
do
|
result
,
line
|
def
formatted_code_for
(
source_code
,
line_counter
,
indent
)
indent_template
=
"%
#{
indent
}
s: %s"
source_code
.
map
do
|
line
|
line_counter
+=
1
if
output
==
:html
result
.
update
(
line_counter
.
to_s
=>
"%
#{
indent
}
s %s
\n
"
%
[
""
,
line
])
else
result
<<
"%
#{
indent
}
s: %s"
%
[
line_counter
,
line
]
end
indent_template
%
[
line_counter
,
line
]
end
end
end
...
...
actionview/test/template/template_error_test.rb
浏览文件 @
e350c4d6
...
...
@@ -34,4 +34,20 @@ def test_provides_useful_inspect
assert_equal
"#<ActionView::Template::Error: original>"
,
error
.
inspect
end
def
test_annotated_source_code_returns_empty_array_if_source_cant_be_found
template
=
Class
.
new
do
def
identifier
"something"
end
end
.
new
error
=
begin
raise
rescue
raise
ActionView
::
Template
::
Error
.
new
(
template
)
rescue
$!
end
assert_equal
[],
error
.
annotated_source_code
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录