Permalink
Browse files

Merged in latest changes from rails/master

  • Loading branch information...
1 parent 418639b commit 63b124b043dec036403f9a88aeafdf99669064e0 @mikel mikel committed Dec 17, 2009
@@ -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 @@ class Base
include AbstractController::Layouts
include AbstractController::Helpers
-
+ helper ActionMailer::MailHelper
+
if Object.const_defined?(:ActionController)
include ActionController::UrlWriter
end
@@ -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 @@ def name_of_the_mailer_class
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

0 comments on commit 63b124b

Please sign in to comment.