Sha256: 5f8189e50218f8be4203cbfbfac1bad2fefffa1e7b56af6f7989633eeccb5fcc

Contents?: true

Size: 639 Bytes

Versions: 2

Compression:

Stored size: 639 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.1.4 lib/prawn_handler.rb
spree_print_invoice-2.1.3 lib/prawn_handler.rb