Class: Tilt::PrawnTemplate

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

Instance Attribute Summary

Attributes inherited from Template

#compiled_path, #data, #file, #line, #options

Instance Method Summary collapse

Methods inherited from Template

#basename, #compiled_method, default_mime_type, default_mime_type=, #eval_file, #fixed_locals?, #initialize, #metadata, metadata, #name, #render

Constructor Details

This class inherits a constructor from Tilt::Template

Instance Method Details

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



27
28
29
30
31
32
33
# File 'lib/tilt/prawn.rb', line 27

def evaluate(scope, locals, &block)
  pdf = ::Prawn::Document.new(@options)
  locals = locals.dup
  locals[:pdf] = pdf
  super
  pdf.render
end

#precompiled_template(locals) ⇒ Object



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

def precompiled_template(locals)
  @data.to_str
end

#prepareObject



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

def prepare
  @options[:page_size] = 'A4' unless @options.has_key?(:page_size)
  @options[:page_layout] = :portrait unless @options.has_key?(:page_layout)
end