-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jonathan Tapia
committed
Jan 29, 2024
1 parent
356ad5a
commit d3ffc2e
Showing
3 changed files
with
32 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'prawn' | ||
|
||
module ActionView | ||
module Template::Handlers | ||
class Prawn | ||
def self.register! | ||
::ActionView::Template.register_template_handler :prawn, self | ||
end | ||
|
||
def self.call(template, source = template.source) | ||
%(extend #{::DocumentProxy}; #{source}; pdf.render) | ||
end | ||
|
||
module DocumentProxy | ||
def pdf | ||
@pdf ||= ::Prawn::Document.new(::Spree::PrintInvoice::Config[:prawn_options]) | ||
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! |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters