Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
ef4c6508
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,发现更多精彩内容 >>
提交
ef4c6508
编写于
4月 19, 2008
作者:
P
Pratik Naik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move missing template logic to ActionView
上级
534c6b24
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
25 addition
and
31 deletion
+25
-31
actionpack/CHANGELOG
actionpack/CHANGELOG
+2
-0
actionpack/lib/action_controller/base.rb
actionpack/lib/action_controller/base.rb
+0
-13
actionpack/lib/action_controller/layout.rb
actionpack/lib/action_controller/layout.rb
+1
-3
actionpack/lib/action_controller/rescue.rb
actionpack/lib/action_controller/rescue.rb
+1
-1
actionpack/lib/action_view/base.rb
actionpack/lib/action_view/base.rb
+3
-0
actionpack/lib/action_view/template.rb
actionpack/lib/action_view/template.rb
+10
-6
actionpack/test/controller/cookie_test.rb
actionpack/test/controller/cookie_test.rb
+1
-1
actionpack/test/controller/flash_test.rb
actionpack/test/controller/flash_test.rb
+1
-1
actionpack/test/controller/layout_test.rb
actionpack/test/controller/layout_test.rb
+1
-1
actionpack/test/controller/mime_responds_test.rb
actionpack/test/controller/mime_responds_test.rb
+1
-1
actionpack/test/controller/new_render_test.rb
actionpack/test/controller/new_render_test.rb
+2
-2
actionpack/test/controller/rescue_test.rb
actionpack/test/controller/rescue_test.rb
+1
-1
actionpack/test/template/template_object_test.rb
actionpack/test/template/template_object_test.rb
+1
-1
未找到文件。
actionpack/CHANGELOG
浏览文件 @
ef4c6508
*
SVN
*
*
Move
missing
template
logic
to
ActionView
.
[
Pratik
]
*
Introduce
ActionView
::
InlineTemplate
class
.
[
Pratik
]
*
Automatically
parse
posted
JSON
content
for
Mime
::
JSON
requests
.
[
rick
]
...
...
actionpack/lib/action_controller/base.rb
浏览文件 @
ef4c6508
...
...
@@ -16,9 +16,6 @@ class ActionControllerError < StandardError #:nodoc:
class
SessionRestoreError
<
ActionControllerError
#:nodoc:
end
class
MissingTemplate
<
ActionControllerError
#:nodoc:
end
class
RenderError
<
ActionControllerError
#:nodoc:
end
...
...
@@ -1105,7 +1102,6 @@ def reset_session #:doc:
private
def
render_for_file
(
template_path
,
status
=
nil
,
use_full_path
=
false
,
locals
=
{})
#:nodoc:
add_variables_to_assigns
assert_existence_of_template_file
(
template_path
)
if
use_full_path
logger
.
info
(
"Rendering
#{
template_path
}
"
+
(
status
?
" (
#{
status
}
)"
:
''
))
if
logger
render_for_text
(
@template
.
render_file
(
template_path
,
use_full_path
,
locals
),
status
)
end
...
...
@@ -1267,15 +1263,6 @@ def template_exempt_from_layout?(template_name = default_template_name)
@@exempt_from_layout
.
any?
{
|
ext
|
name_with_extension
=~
ext
}
end
def
assert_existence_of_template_file
(
template_name
)
unless
template_exists?
(
template_name
)
||
ignore_missing_templates
full_template_path
=
template_name
.
include?
(
'.'
)
?
template_name
:
"
#{
template_name
}
.
#{
@template
.
template_format
}
.erb"
display_paths
=
view_paths
.
join
(
':'
)
template_type
=
(
template_name
=~
/layouts/i
)
?
'layout'
:
'template'
raise
(
MissingTemplate
,
"Missing
#{
template_type
}
#{
full_template_path
}
in view path
#{
display_paths
}
"
)
end
end
def
default_template_name
(
action_name
=
self
.
action_name
)
if
action_name
action_name
=
action_name
.
to_s
...
...
actionpack/lib/action_controller/layout.rb
浏览文件 @
ef4c6508
...
...
@@ -244,9 +244,7 @@ def active_layout(passed_layout = nil)
def
render_with_a_layout
(
options
=
nil
,
extra_options
=
{},
&
block
)
#:nodoc:
template_with_options
=
options
.
is_a?
(
Hash
)
if
apply_layout?
(
template_with_options
,
options
)
&&
(
layout
=
pick_layout
(
template_with_options
,
options
))
assert_existence_of_template_file
(
layout
)
if
(
layout
=
pick_layout
(
template_with_options
,
options
))
&&
apply_layout?
(
template_with_options
,
options
)
options
=
options
.
merge
:layout
=>
false
if
template_with_options
logger
.
info
(
"Rendering template within
#{
layout
}
"
)
if
logger
...
...
actionpack/lib/action_controller/rescue.rb
浏览文件 @
ef4c6508
...
...
@@ -26,7 +26,7 @@ module Rescue
DEFAULT_RESCUE_TEMPLATE
=
'diagnostics'
DEFAULT_RESCUE_TEMPLATES
=
{
'Action
Controller::MissingTemplate'
=>
'missing_template'
,
'Action
View::MissingTemplate'
=>
'missing_template'
,
'ActionController::RoutingError'
=>
'routing_error'
,
'ActionController::UnknownAction'
=>
'unknown_action'
,
'ActionView::TemplateError'
=>
'template_error'
...
...
actionpack/lib/action_view/base.rb
浏览文件 @
ef4c6508
module
ActionView
#:nodoc:
class
ActionViewError
<
StandardError
#:nodoc:
end
class
MissingTemplate
<
ActionViewError
#:nodoc:
end
# Action View templates can be written in three ways. If the template file has a +.erb+ (or +.rhtml+) extension then it uses a mixture of ERb
# (included in Ruby) and HTML. If the template file has a +.builder+ (or +.rxml+) extension then Jim Weirich's Builder::XmlMarkup library is used.
...
...
actionpack/lib/action_view/template.rb
浏览文件 @
ef4c6508
...
...
@@ -54,9 +54,8 @@ def set_extension_and_file_name(use_full_path)
@filename
=
@finder
.
pick_template
(
@path_without_extension
,
@extension
)
else
@extension
=
@finder
.
pick_template_extension
(
@path
).
to_s
unless
@extension
raise
ActionViewError
,
"No template found for
#{
@path
}
in
#{
@finder
.
view_paths
.
inspect
}
"
end
raise_missing_template_exception
unless
@extension
@filename
=
@finder
.
pick_template
(
@path
,
@extension
)
@extension
=
@extension
.
gsub
(
/^.+\./
,
''
)
# strip off any formats
end
...
...
@@ -64,9 +63,14 @@ def set_extension_and_file_name(use_full_path)
@filename
=
@path
end
if
@filename
.
blank?
raise
ActionViewError
,
"Couldn't find template file for
#{
@path
}
in
#{
@finder
.
view_paths
.
inspect
}
"
end
raise_missing_template_exception
if
@filename
.
blank?
end
def
raise_missing_template_exception
full_template_path
=
@path
.
include?
(
'.'
)
?
@path
:
"
#{
@path
}
.
#{
@view
.
template_format
}
.erb"
display_paths
=
@finder
.
view_paths
.
join
(
':'
)
template_type
=
(
@path
=~
/layouts/i
)
?
'layout'
:
'template'
raise
(
MissingTemplate
,
"Missing
#{
template_type
}
#{
full_template_path
}
in view path
#{
display_paths
}
"
)
end
# Template Handlers
...
...
actionpack/test/controller/cookie_test.rb
浏览文件 @
ef4c6508
...
...
@@ -37,7 +37,7 @@ def authenticate_with_http_only
end
def
rescue_action
(
e
)
raise
unless
Action
Controller
::
MissingTemplate
# No templates here, and we don't care about the output
raise
unless
Action
View
::
MissingTemplate
# No templates here, and we don't care about the output
end
end
...
...
actionpack/test/controller/flash_test.rb
浏览文件 @
ef4c6508
...
...
@@ -52,7 +52,7 @@ def use_flash_after_reset_session
end
def
rescue_action
(
e
)
raise
unless
Action
Controller
::
MissingTemplate
===
e
raise
unless
Action
View
::
MissingTemplate
===
e
end
# methods for test_sweep_after_halted_filter_chain
...
...
actionpack/test/controller/layout_test.rb
浏览文件 @
ef4c6508
...
...
@@ -216,7 +216,7 @@ def test_exception_raised_when_layout_file_not_found
@controller
=
SetsNonExistentLayoutFile
.
new
get
:hello
@response
.
template
.
class
.
module_eval
{
attr_accessor
:exception
}
assert_equal
Action
Controller
::
MissingTemplate
,
@response
.
template
.
exception
.
class
assert_equal
Action
View
::
MissingTemplate
,
@response
.
template
.
exception
.
class
end
end
...
...
actionpack/test/controller/mime_responds_test.rb
浏览文件 @
ef4c6508
...
...
@@ -468,7 +468,7 @@ def test_format_with_custom_response_type_and_request_headers_with_only_one_layo
assert_equal
'<html><div id="html_missing">Hello future from Firefox!</div></html>'
,
@response
.
body
@request
.
env
[
"HTTP_ACCEPT"
]
=
"text/iphone"
assert_raises
(
Action
Controller
::
MissingTemplate
)
{
get
:iphone_with_html_response_type_without_layout
}
assert_raises
(
Action
View
::
MissingTemplate
)
{
get
:iphone_with_html_response_type_without_layout
}
end
end
...
...
actionpack/test/controller/new_render_test.rb
浏览文件 @
ef4c6508
...
...
@@ -652,7 +652,7 @@ def test_render_to_string_partial
end
def
test_bad_render_to_string_still_throws_exception
assert_raises
(
Action
Controller
::
MissingTemplate
)
{
get
:render_to_string_with_exception
}
assert_raises
(
Action
View
::
MissingTemplate
)
{
get
:render_to_string_with_exception
}
end
def
test_render_to_string_that_throws_caught_exception_doesnt_break_assigns
...
...
@@ -787,7 +787,7 @@ def test_partial_with_implicit_local_assignment
end
def
test_render_missing_partial_template
assert_raises
(
ActionView
::
ActionViewError
)
do
assert_raises
(
ActionView
::
MissingTemplate
)
do
get
:missing_partial
end
end
...
...
actionpack/test/controller/rescue_test.rb
浏览文件 @
ef4c6508
...
...
@@ -279,7 +279,7 @@ def test_rescue_templates
assert_equal
ActionController
::
Rescue
::
DEFAULT_RESCUE_TEMPLATE
,
templates
.
default
assert_equal
ActionController
::
Rescue
::
DEFAULT_RESCUE_TEMPLATE
,
templates
[
Exception
.
new
]
assert_equal
'missing_template'
,
templates
[
Action
Controller
::
MissingTemplate
.
name
]
assert_equal
'missing_template'
,
templates
[
Action
View
::
MissingTemplate
.
name
]
assert_equal
'routing_error'
,
templates
[
ActionController
::
RoutingError
.
name
]
assert_equal
'unknown_action'
,
templates
[
ActionController
::
UnknownAction
.
name
]
assert_equal
'template_error'
,
templates
[
ActionView
::
TemplateError
.
name
]
...
...
actionpack/test/template/template_object_test.rb
浏览文件 @
ef4c6508
...
...
@@ -82,7 +82,7 @@ def test_js
def
test_xml
@view
.
template_format
=
:xml
assert_raise
ActionView
::
ActionViewError
do
assert_raise
ActionView
::
MissingTemplate
do
ActionView
::
PartialTemplate
.
new
(
@view
,
@path
,
nil
)
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录