Class: Tilt::PrawnTemplate
Overview
Prawn template implementation. See: prawnpdf.org
Instance Attribute Summary
Attributes inherited from Template
#compiled_path, #data, #file, #line, #options
Instance Method Summary collapse
- #allows_script? ⇒ Boolean
- #evaluate(scope, locals, &block) ⇒ Object
- #precompiled_template(locals) ⇒ Object
- #prepare ⇒ Object
Methods inherited from Template
#basename, default_mime_type, default_mime_type=, #eval_file, #initialize, metadata, #metadata, #name, #render
Constructor Details
This class inherits a constructor from Tilt::Template
Instance Method Details
#allows_script? ⇒ Boolean
25 26 27 |
# File 'lib/tilt/prawn.rb', line 25 def allows_script? false end |
#evaluate(scope, locals, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/tilt/prawn.rb', line 14 def evaluate(scope, locals, &block) pdf = @engine if data.respond_to?(:to_str) locals[:pdf] = pdf super(scope, locals, &block) elsif data.kind_of?(Proc) data.call(pdf) end @output ||= pdf.render end |
#precompiled_template(locals) ⇒ Object
29 30 31 |
# File 'lib/tilt/prawn.rb', line 29 def precompiled_template(locals) data.to_str end |
#prepare ⇒ Object
10 11 12 |
# File 'lib/tilt/prawn.rb', line 10 def prepare @engine = ::Prawn::Document.new() end |