mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Merged in latest changes from rails/master
This commit is contained in:
@@ -34,11 +34,12 @@ module ActionMailer
|
||||
autoload :DeprecatedBody
|
||||
autoload :Base
|
||||
autoload :DeliveryMethod
|
||||
autoload :MailHelper
|
||||
autoload :Part
|
||||
autoload :PartContainer
|
||||
autoload :Quoting
|
||||
autoload :TestCase
|
||||
autoload :TestHelper
|
||||
|
||||
end
|
||||
|
||||
module Text
|
||||
|
||||
@@ -258,7 +258,8 @@ module ActionMailer #:nodoc:
|
||||
include AbstractController::Layouts
|
||||
|
||||
include AbstractController::Helpers
|
||||
|
||||
helper ActionMailer::MailHelper
|
||||
|
||||
if Object.const_defined?(:ActionController)
|
||||
include ActionController::UrlWriter
|
||||
end
|
||||
|
||||
19
actionmailer/lib/action_mailer/mail_helper.rb
Normal file
19
actionmailer/lib/action_mailer/mail_helper.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
module ActionMailer
|
||||
module MailHelper
|
||||
# Uses Text::Format to take the text and format it, indented two spaces for
|
||||
# each line, and wrapped at 72 columns.
|
||||
def block_format(text)
|
||||
formatted = text.split(/\n\r\n/).collect { |paragraph|
|
||||
Text::Format.new(
|
||||
:columns => 72, :first_indent => 2, :body_indent => 2, :text => paragraph
|
||||
).format
|
||||
}.join("\n")
|
||||
|
||||
# Make list points stand on their own line
|
||||
formatted.gsub!(/[ ]*([*]+) ([^*]*)/) { |s| " #{$1} #{$2.strip}\n" }
|
||||
formatted.gsub!(/[ ]*([#]+) ([^#]*)/) { |s| " #{$1} #{$2.strip}\n" }
|
||||
|
||||
formatted
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -56,7 +56,7 @@ end
|
||||
class MailerHelperTest < Test::Unit::TestCase
|
||||
def new_mail( charset="utf-8" )
|
||||
mail = Mail.new
|
||||
mail.content_type(["text", "plain", { "charset" => charset }])
|
||||
mail.set_content_type "text", "plain", { "charset" => charset } if charset
|
||||
mail
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user