Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merged in latest changes from rails/master

  • Loading branch information...
commit 63b124b043dec036403f9a88aeafdf99669064e0 1 parent 418639b
@mikel mikel authored
View
3  actionmailer/lib/action_mailer.rb
@@ -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
View
3  actionmailer/lib/action_mailer/base.rb
@@ -258,7 +258,8 @@ class Base
include AbstractController::Layouts
include AbstractController::Helpers
-
+ helper ActionMailer::MailHelper
+
if Object.const_defined?(:ActionController)
include ActionController::UrlWriter
end
View
19 actionmailer/lib/action_mailer/mail_helper.rb
@@ -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
View
2  actionmailer/test/mail_helper_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.