Sha256: b21866a6a506c8fa2519fad846ff5ba9f80a9462480b63f406b7a309ba906925
Contents?: true
Size: 910 Bytes
Versions: 2
Compression:
Stored size: 910 Bytes
Contents
require_relative "template" module PrawnCocktail class Renderer def initialize(template_name, data, doc_initializers) @template_name = template_name @data = data @doc_initializers = doc_initializers end def meta(opts) @prawn_document_options = opts end def content(&block) @doc_initializers.each do |proc| prawn_document.instance_eval(&proc) end prawn_document.instance_exec(data_object, &block) end def render_data apply_template prawn_document.render end def render_file(file) apply_template prawn_document.render_file(file) end private def apply_template Template.new(@template_name).apply(self) end def prawn_document @doc ||= Prawn::Document.new(@prawn_document_options || {}) end def data_object OpenStruct.new(@data) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
prawn_cocktail-0.5.4 | lib/prawn_cocktail/renderer.rb |
prawn_cocktail-0.5.3 | lib/prawn_cocktail/renderer.rb |