Permalink
Browse files

Pass :handlers & :formats to render when they are specified (closes #87)

  • Loading branch information...
unixmonkey committed Mar 14, 2012
1 parent 2933712 commit 366a0b87a8e17ee5d1f84c32141978426e9272c4
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/pdf_helper.rb
View
@@ -51,7 +51,7 @@ def clean_temp_files
end
def make_pdf(options = {})
- html_string = render_to_string(:template => options[:template], :layout => options[:layout])
+ html_string = render_to_string(:template => options[:template], :layout => options[:layout], :formats => options[:formats], :handlers => options[:handlers])
options = prerender_header_and_footer(options)
w = WickedPdf.new(options[:wkhtmltopdf])
w.pdf_from_string(html_string, options)
@@ -63,7 +63,7 @@ def make_and_send_pdf(pdf_name, options={})
options[:template] ||= File.join(controller_path, action_name)
options[:disposition] ||= "inline"
if options[:show_as_html]
- render :template => options[:template], :layout => options[:layout], :content_type => "text/html"
+ render :template => options[:template], :layout => options[:layout], :formats => options[:formats], :handlers => options[:handlers], :content_type => "text/html"
else
pdf_content = make_pdf(options)
File.open(options[:save_to_file], 'wb') {|file| file << pdf_content } if options[:save_to_file]
@@ -79,7 +79,7 @@ def prerender_header_and_footer(options)
@hf_tempfiles = [] if ! defined?(@hf_tempfiles)
@hf_tempfiles.push( tf=WickedPdfTempfile.new("wicked_#{hf}_pdf.html") )
options[hf][:html][:layout] ||= options[:layout]
- tf.write render_to_string(:template => options[hf][:html][:template], :layout => options[hf][:html][:layout], :locals => options[hf][:html][:locals])
+ tf.write render_to_string(:template => options[hf][:html][:template], :layout => options[hf][:html][:layout], :locals => options[hf][:html][:locals], :formats => options[hf][:html][:formats], :handlers => options[hf][:html][:handlers])
tf.flush
options[hf][:html].delete(:template)
options[hf][:html][:url] = "file://#{tf.path}"

0 comments on commit 366a0b8

Please sign in to comment.