Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
36c6aa01
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,发现更多精彩内容 >>
提交
36c6aa01
编写于
9月 09, 2008
作者:
D
David Heinemeier Hansson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "Add layout functionality to mailers."
This reverts commit
e9a8e005
.
上级
1398db01
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
3 addition
and
115 deletion
+3
-115
actionmailer/CHANGELOG
actionmailer/CHANGELOG
+0
-5
actionmailer/lib/action_mailer/base.rb
actionmailer/lib/action_mailer/base.rb
+2
-22
actionmailer/test/fixtures/auto_layout_mailer/hello.html.erb
actionmailer/test/fixtures/auto_layout_mailer/hello.html.erb
+0
-1
actionmailer/test/fixtures/explicit_layout_mailer/logout.html.erb
...iler/test/fixtures/explicit_layout_mailer/logout.html.erb
+0
-1
actionmailer/test/fixtures/explicit_layout_mailer/signup.html.erb
...iler/test/fixtures/explicit_layout_mailer/signup.html.erb
+0
-1
actionmailer/test/fixtures/layouts/auto_layout_mailer.html.erb
...nmailer/test/fixtures/layouts/auto_layout_mailer.html.erb
+0
-1
actionmailer/test/fixtures/layouts/spam.html.erb
actionmailer/test/fixtures/layouts/spam.html.erb
+0
-1
actionmailer/test/mail_layout_test.rb
actionmailer/test/mail_layout_test.rb
+0
-78
actionpack/lib/action_controller/layout.rb
actionpack/lib/action_controller/layout.rb
+1
-5
未找到文件。
actionmailer/CHANGELOG
浏览文件 @
36c6aa01
* Add layout functionality to mailers [Pratik]
Mailer layouts behaves just like controller layouts, except layout names need to
have '_mailer' postfix for them to be automatically picked up.
*2.1.0 (May 31st, 2008)*
* Fixed that a return-path header would be ignored #7572 [joost]
...
...
actionmailer/lib/action_mailer/base.rb
浏览文件 @
36c6aa01
...
...
@@ -246,10 +246,7 @@ module ActionMailer #:nodoc:
# +implicit_parts_order+.
class
Base
include
AdvAttrAccessor
,
PartContainer
if
Object
.
const_defined?
(
:ActionController
)
include
ActionController
::
UrlWriter
include
ActionController
::
Layout
end
include
ActionController
::
UrlWriter
if
Object
.
const_defined?
(
:ActionController
)
private_class_method
:new
#:nodoc:
...
...
@@ -365,7 +362,6 @@ def mailer_name=(value)
# The mail object instance referenced by this mailer.
attr_reader
:mail
attr_reader
:template_name
,
:default_template_name
,
:action_name
class
<<
self
attr_writer
:mailer_name
...
...
@@ -534,7 +530,6 @@ def initialize_defaults(method_name)
@content_type
||=
@@default_content_type
.
dup
@implicit_parts_order
||=
@@default_implicit_parts_order
.
dup
@template
||=
method_name
@default_template_name
=
@action_name
=
@template
@mailer_name
||=
self
.
class
.
name
.
underscore
@parts
||=
[]
@headers
||=
{}
...
...
@@ -551,22 +546,7 @@ def render(opts)
if
opts
[
:file
]
&&
(
opts
[
:file
]
!~
/\//
&&
!
opts
[
:file
].
respond_to?
(
:render
))
opts
[
:file
]
=
"
#{
mailer_name
}
/
#{
opts
[
:file
]
}
"
end
begin
old_template
,
@template
=
@template
,
initialize_template_class
(
body
)
layout
=
respond_to?
(
:pick_layout
,
true
)
?
pick_layout
(
opts
)
:
false
@template
.
render
(
opts
.
merge
(
:layout
=>
layout
))
ensure
@template
=
old_template
end
end
def
default_template_format
:html
end
def
candidate_for_layout?
(
options
)
!
@template
.
send
(
:_exempt_from_layout?
,
default_template_name
)
initialize_template_class
(
body
).
render
(
opts
)
end
def
template_root
...
...
actionmailer/test/fixtures/auto_layout_mailer/hello.html.erb
已删除
100644 → 0
浏览文件 @
1398db01
Inside
\ No newline at end of file
actionmailer/test/fixtures/explicit_layout_mailer/logout.html.erb
已删除
100644 → 0
浏览文件 @
1398db01
You logged out
\ No newline at end of file
actionmailer/test/fixtures/explicit_layout_mailer/signup.html.erb
已删除
100644 → 0
浏览文件 @
1398db01
We do not spam
\ No newline at end of file
actionmailer/test/fixtures/layouts/auto_layout_mailer.html.erb
已删除
100644 → 0
浏览文件 @
1398db01
Hello from layout
<%=
yield
%>
\ No newline at end of file
actionmailer/test/fixtures/layouts/spam.html.erb
已删除
100644 → 0
浏览文件 @
1398db01
Spammer layout
<%=
yield
%>
\ No newline at end of file
actionmailer/test/mail_layout_test.rb
已删除
100644 → 0
浏览文件 @
1398db01
require
'abstract_unit'
class
AutoLayoutMailer
<
ActionMailer
::
Base
def
hello
(
recipient
)
recipients
recipient
subject
"You have a mail"
from
"tester@example.com"
end
def
spam
(
recipient
)
recipients
recipient
subject
"You have a mail"
from
"tester@example.com"
body
render
(
:inline
=>
"Hello, <%= @world %>"
,
:layout
=>
'spam'
,
:body
=>
{
:world
=>
"Earth"
})
end
def
nolayout
(
recipient
)
recipients
recipient
subject
"You have a mail"
from
"tester@example.com"
body
render
(
:inline
=>
"Hello, <%= @world %>"
,
:layout
=>
false
,
:body
=>
{
:world
=>
"Earth"
})
end
end
class
ExplicitLayoutMailer
<
ActionMailer
::
Base
layout
'spam'
,
:except
=>
[
:logout
]
def
signup
(
recipient
)
recipients
recipient
subject
"You have a mail"
from
"tester@example.com"
end
def
logout
(
recipient
)
recipients
recipient
subject
"You have a mail"
from
"tester@example.com"
end
end
class
LayoutMailerTest
<
Test
::
Unit
::
TestCase
def
setup
set_delivery_method
:test
ActionMailer
::
Base
.
perform_deliveries
=
true
ActionMailer
::
Base
.
deliveries
=
[]
@recipient
=
'test@localhost'
end
def
teardown
restore_delivery_method
end
def
test_should_pickup_default_layout
mail
=
AutoLayoutMailer
.
create_hello
(
@recipient
)
assert_equal
"Hello from layout Inside"
,
mail
.
body
.
strip
end
def
test_should_pickup_layout_given_to_render
mail
=
AutoLayoutMailer
.
create_spam
(
@recipient
)
assert_equal
"Spammer layout Hello, Earth"
,
mail
.
body
.
strip
end
def
test_should_respect_layout_false
mail
=
AutoLayoutMailer
.
create_nolayout
(
@recipient
)
assert_equal
"Hello, Earth"
,
mail
.
body
.
strip
end
def
test_explicit_class_layout
mail
=
ExplicitLayoutMailer
.
create_signup
(
@recipient
)
assert_equal
"Spammer layout We do not spam"
,
mail
.
body
.
strip
end
def
test_explicit_layout_exceptions
mail
=
ExplicitLayoutMailer
.
create_logout
(
@recipient
)
assert_equal
"You logged out"
,
mail
.
body
.
strip
end
end
actionpack/lib/action_controller/layout.rb
浏览文件 @
36c6aa01
...
...
@@ -216,7 +216,7 @@ def default_layout_with_format(format, layout)
# object). If the layout was defined without a directory, layouts is assumed. So <tt>layout "weblog/standard"</tt> will return
# weblog/standard, but <tt>layout "standard"</tt> will return layouts/standard.
def
active_layout
(
passed_layout
=
nil
)
layout
=
passed_layout
||
self
.
class
.
default_layout
(
default_
template_format
)
layout
=
passed_layout
||
self
.
class
.
default_layout
(
response
.
template
.
template_format
)
active_layout
=
case
layout
when
String
then
layout
when
Symbol
then
__send__
(
layout
)
...
...
@@ -276,9 +276,5 @@ def layout_directory?(layout_name)
rescue
ActionView
::
MissingTemplate
false
end
def
default_template_format
response
.
template
.
template_format
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录