Class: Tilt::PrawnTemplate

Inherits:
Template
  • Object
show all
Defined in:
lib/sinatra/prawn.rb

Instance Method Summary collapse

Instance Method Details

#evaluate(scope, locals, &block) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/sinatra/prawn.rb', line 38

def evaluate(scope, locals, &block)
  pdf = ::Prawn::Document.new
  if data.respond_to?(:to_str)
    locals[:pdf] = pdf
    super(scope, locals, &block)
  elsif data.kind_of?(Proc)
    data.call(pdf)
  end
  pdf.render
end

#initialize_engineObject



29
30
31
32
33
# File 'lib/sinatra/prawn.rb', line 29

def initialize_engine
  return if defined? ::Prawn::Document
  require_template_library 'prawn'
  require_template_library 'prawn/layout'
end

#precompiled_template(locals) ⇒ Object



49
50
51
# File 'lib/sinatra/prawn.rb', line 49

def precompiled_template(locals)
  data.to_str
end

#prepareObject



35
36
# File 'lib/sinatra/prawn.rb', line 35

def prepare
end