Sha256: c35e525055193f4c461a49f88b861f40e09374bcbcdf8bc106d8dd06a422b666

Contents?: true

Size: 1.46 KB

Versions: 24

Compression:

Stored size: 1.46 KB

Contents

begin
  require 'tilt'
rescue LoadError
  require 'sinatra/tilt'
end

module Padrino
  ##
  # This component uses the +mail+ library to create a powerful but simple
  # mailer within Padrino (and Sinatra).
  # There is full support for using plain or html content-types as well as for file attachments.
  #
  # Using the mailer in Padrino has two forms. The 'quick' method requires only use
  # of the +email+ method directly in the controller:
  #
  #  # app/controllers/session.rb
  #  post :create do
  #    email do
  #      from "tony@reyes.com"
  #      to "john@smith.com"
  #      subject "Welcome!"
  #      body render('email/registered')
  #    end
  #  end
  #
  module Mailer
    class << self
      ##
      # Registers the Padrino::Mailer helpers with the application.
      #
      # @param [Sinatra::Application] app The application that needs mailers.
      #
      # @example
      #   require 'padrino-mailer'
      #   class Demo < Padrino::Application
      #     register Padrino::Mailer::Helpers
      #   end
      #
      def registered(app)
        require 'padrino-mailer/base'
        require 'padrino-mailer/helpers'
        require 'padrino-mailer/mime'
        # This lazily loads the mail gem, due to its long require time.
        app.set :_padrino_mailer, proc {
          require 'padrino-mailer/ext'
          app._padrino_mailer = Mail
        }
        app.helpers Padrino::Mailer::Helpers
      end
      alias :included :registered
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
padrino-mailer-0.15.0 lib/padrino-mailer.rb
padrino-mailer-0.14.4 lib/padrino-mailer.rb
padrino-mailer-0.14.3 lib/padrino-mailer.rb
padrino-mailer-0.12.9 lib/padrino-mailer.rb
padrino-mailer-0.14.2 lib/padrino-mailer.rb
padrino-mailer-0.13.3.4 lib/padrino-mailer.rb
padrino-mailer-0.14.1.1 lib/padrino-mailer.rb
padrino-mailer-0.14.1 lib/padrino-mailer.rb
padrino-mailer-0.14.0.2 lib/padrino-mailer.rb
padrino-mailer-0.14.0.1 lib/padrino-mailer.rb
padrino-mailer-0.14.0 lib/padrino-mailer.rb
padrino-mailer-0.14.0.rc2 lib/padrino-mailer.rb
padrino-mailer-0.14.0.rc1 lib/padrino-mailer.rb
padrino-mailer-0.13.3.3 lib/padrino-mailer.rb
padrino-mailer-0.13.3.2 lib/padrino-mailer.rb
padrino-mailer-0.13.3.1 lib/padrino-mailer.rb
padrino-mailer-0.13.3 lib/padrino-mailer.rb
padrino-mailer-0.13.2 lib/padrino-mailer.rb
padrino-mailer-0.13.1 lib/padrino-mailer.rb
padrino-mailer-0.13.1.beta1 lib/padrino-mailer.rb