Class: Tilt::PrawnTemplate

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

Defined Under Namespace

Classes: Engine

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.engineObject

Returns the value of attribute engine.



11
12
13
# File 'lib/tilt/prawn.rb', line 11

def engine
  @engine
end

Class Method Details

.extend_engine(&block) ⇒ Object



24
25
26
# File 'lib/tilt/prawn.rb', line 24

def self.extend_engine(&block)
  Engine.class_eval(&block)
end

.reset_engine!Object



13
14
15
16
17
18
# File 'lib/tilt/prawn.rb', line 13

def reset_engine!
  self.engine = Engine
  Engine.instance_methods(false).each do |method|
    Engine.send(:undef_method, method)
  end
end

Instance Method Details

#engineObject



31
32
33
# File 'lib/tilt/prawn.rb', line 31

def engine
  @options[:engine] || self.class.engine
end

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



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/tilt/prawn.rb', line 35

def evaluate(scope, locals, &block)
  scope = scope ? scope.dup : Object.new
  pdf = engine.new
  if data.respond_to?(:call)
    locals.each do |key, val|
      scope.define_singleton_method(key) { val }
    end
    scope.instance_exec(pdf, &data)
  else
    locals[:pdf] = pdf
    super(scope, locals, &block)
  end
  pdf.render
end

#precompiled_template(local_keys) ⇒ Object



50
51
52
# File 'lib/tilt/prawn.rb', line 50

def precompiled_template(local_keys)
  data
end

#prepareObject



28
29
# File 'lib/tilt/prawn.rb', line 28

def prepare
end