Sha256: 6c1742684acc0e09972de1ac4c52a8b8c2a0847c97a1c50434ba919a488ff5ba
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
require "prawn" require_relative "template" require_relative "utils/recursive_closed_struct" module PrawnCocktail class Renderer def initialize(template_name, data, initializers) @prawn_document_options = {} @template_name = template_name @data = data @initializers = initializers end def meta(opts) @prawn_document_options.merge!(opts) end def content(&block) @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 prawn_document_options @prawn_document_options || {} end def data_object RecursiveClosedStruct.new(@data) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
prawn_cocktail-0.8.1 | lib/prawn_cocktail/renderer.rb |