Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 0.1.3
* Make PDF document persistent across the view rendering process - fixes layout and partials using separate 'pdf' local instance
## 0.1.1
* Fixed undefined Mime::PDF for Rails 5.
5 changes: 1 addition & 4 deletions lib/prawnto/template_handler/compile_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def set_cache_control
end

def set_content_type
@controller.response.content_type ||= Mime::PDF
@controller.response.content_type ||= Mime::EXTENSION_LOOKUP['pdf']
end

def set_disposition
Expand All @@ -65,6 +65,3 @@ def set_disposition

end
end



10 changes: 7 additions & 3 deletions lib/prawnto/template_handlers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ class Base < (base_class_for_template_handler_required? ? ::ActionView::Template
include ::ActionView::TemplateHandlers::Compilable if template_should_include_compilable?

def self.call(template)
##
# DVB
# Let's make the prawn pdf document persistent across layouts
# and partials through an instance variable
"@pdf ||= Prawn::Document.new(@prawnto_options[:prawn]);" +
"_prawnto_compile_setup;" +
"pdf = Prawn::Document.new(@prawnto_options[:prawn]);" +
# "pdf = Prawn::Document.new(@prawnto_options[:prawn]);" +
"pdf = @pdf;" +
"#{template.source}\n" +
"pdf.render;"
end
Expand All @@ -20,5 +26,3 @@ def compile(template)
end
end
end


4 changes: 2 additions & 2 deletions lib/prawnto/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Prawnto
VERSION = '0.1.1'
end
VERSION = '0.1.3'
end
2 changes: 1 addition & 1 deletion prawnto.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Gem::Specification.new do |s|
# specify any dependencies here; for example:
# s.add_development_dependency "rspec"
s.add_runtime_dependency "prawn"
s.add_runtime_dependency 'rails', '>=2.1'
s.add_runtime_dependency 'rails', '>=5.0'
end