Sha256: 7b0375e8a006e9e5487f2670b28d1181f89f63f765640971f6b6d59b298c59b8
Contents?: true
Size: 1002 Bytes
Versions: 3
Compression:
Stored size: 1002 Bytes
Contents
module PrawnCocktail class Renderer def initialize(template, data, doc_initializers) @template = template @data = data @doc_initializers = doc_initializers end def meta(opts) @prawn_document_options = opts end def content(&block) @doc_initializers.each do |proc| doc.instance_eval(&proc) end doc.instance_exec(data_object, &block) end def render_data render doc.render end def render_file(file) render doc.render_file(file) end private def render instance_eval(read_template, template_path) end def doc @doc ||= Prawn::Document.new(@prawn_document_options || {}) end def data_object OpenStruct.new(@data) end def read_template File.read(template_path) end def template_path File.join(template_root, "#{@template}.pdf.rb") end def template_root PrawnCocktail.template_root end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
prawn_cocktail-0.5.1 | lib/prawn_cocktail/renderer.rb |
prawn_cocktail-0.5.0 | lib/prawn_cocktail/renderer.rb |
prawn_cocktail-0.4.0 | lib/prawn_cocktail/renderer.rb |