Skip to content

Instantly share code, notes, and snippets.

@bouchard
Created November 14, 2008 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bouchard/25073 to your computer and use it in GitHub Desktop.
Save bouchard/25073 to your computer and use it in GitHub Desktop.
From b203bad71d53c4278dc97c30c0827b0430bae3ad Mon Sep 17 00:00:00 2001
From: Brady Bouchard <brady@lunardawn.ca>
Date: Fri, 14 Nov 2008 13:20:04 -0700
Subject: [PATCH] Added basic support for Rails 2.2 using compiled templates.
Options that affect the response header (pragma, cache-control, content-disposition) are not enabled.
Options passed to Prawn work as usual.
---
lib/prawnto/template_handler/base.rb | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/lib/prawnto/template_handler/base.rb b/lib/prawnto/template_handler/base.rb
index d772561..8241c23 100644
--- a/lib/prawnto/template_handler/base.rb
+++ b/lib/prawnto/template_handler/base.rb
@@ -68,6 +68,14 @@ module Prawnto
@view.instance_eval source, template.filename, 1
pdf.render
end
+
+ def compile(template)
+ "@prawnto_options = @controller.send :compute_prawnto_options;" +
+ "_set_controller_content_type(Mime::PDF);" +
+ "pdf = ::Prawn::Document.new(@prawnto_options[:prawn]);" +
+ template.source +
+ ";pdf.render;"
+ end
end
end
--
1.6.0.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment