Skip to content

New helpers in 1.3 #4

Merged
merged 1 commit into from Nov 19, 2011
+17 −11
View
28 lib/sinatra/prawn.rb
@@ -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
Something went wrong with that request. Please try again.