Sha256: e774fe03eebd7fda3ba44f2bccb2fccac8ad05da5b6a9aa8f77f2296589c5613

Contents?: true

Size: 793 Bytes

Versions: 3

Compression:

Stored size: 793 Bytes

Contents

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

    # Access the mailer instance.
    def mailer
      @_controller
    end

    # Access the message instance.
    def message
      @_message
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
actionmailer-3.0.0.beta3 lib/action_mailer/mail_helper.rb
actionmailer-3.0.0.beta2 lib/action_mailer/mail_helper.rb
actionmailer-3.0.0.beta lib/action_mailer/mail_helper.rb