Permalink
Browse files

now works with sinatra 1.3

  • Loading branch information...
1 parent d80de95 commit 47fea551c03fda26252bb9b480eea113f6d4dd0e @mk0x9 mk0x9 committed Nov 19, 2011
Showing with 17 additions and 11 deletions.
  1. +17 −11 lib/sinatra/prawn.rb
View
@@ -2,19 +2,25 @@
module Sinatra
module Prawn
- # Generate pdf file using Prawn.
- # Takes the name of a template to render as a Symbol and returns a String with the rendered output.
- #
- # Options for prawn may be specified in Sinatra using set :prawn, { ... }
- def prawn(template=nil, options={}, locals = {}, &block)
- options, template = template, nil if template.is_a?(Hash)
- template = lambda { block } if template.nil?
- options[:layout] = false
- render :prawn, template, options, locals
+ module Helpers
+ # Generate pdf file using Prawn.
+ # Takes the name of a template to render as a Symbol and returns a String with the rendered output.
+ #
+ # Options for prawn may be specified in Sinatra using set :prawn, { ... }
+ def prawn(template=nil, options={}, locals = {}, &block)
+ options, template = template, nil if template.is_a?(Hash)
+ template = lambda { block } if template.nil?
+ options[:layout] = false
+ render :prawn, template, options, locals
+ end
+ end
+
+ def self.registered(app)
+ app.helpers Prawn::Helpers
end
end
- helpers Prawn
+ register Prawn
end
@@ -45,4 +51,4 @@ def precompiled_template(locals)
end
end
register 'prawn', PrawnTemplate
-end
+end

0 comments on commit 47fea55

Please sign in to comment.