Sha256: 9d07a48111a9fea66d295c38c73706a5a9cd438deac126fb1f90202db77cc0e3

Contents?: true

Size: 606 Bytes

Versions: 2

Compression:

Stored size: 606 Bytes

Contents

require 'prawn'

module ActionView
  module Template::Handlers
    class Prawn
      def self.register!
        Template.register_template_handler :prawn, self
      end

      def self.call(template)
        %(extend #{DocumentProxy}; #{template.source}; pdf.render)
      end

      module DocumentProxy
        def pdf
          @pdf ||= ::Prawn::Document.new
        end

      private

        def method_missing(method, *args, &block)
          pdf.respond_to?(method) ? pdf.send(method, *args, &block) : super
        end
      end
    end
  end
end

ActionView::Template::Handlers::Prawn.register!

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree-print-invoice-2.2.0 lib/prawn_handler.rb
spree-print-invoice-2.1.0 lib/prawn_handler.rb