Skip to content

Commit

Permalink
Merge pull request #4 from tensai-cirno/master
Browse files Browse the repository at this point in the history
New helpers in 1.3
  • Loading branch information
S. Brent Faulkner committed Nov 19, 2011
2 parents 4976f57 + 47fea55 commit 05fbd75
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions lib/sinatra/prawn.rb
Expand Up @@ -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


Expand Down Expand Up @@ -45,4 +51,4 @@ def precompiled_template(locals)
end
end
register 'prawn', PrawnTemplate
end
end

0 comments on commit 05fbd75

Please sign in to comment.