Sha256: 6b01f4a37430cf4c2e7869943607921058cffef82cc94ae46ce5587213b0c60b
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
module Skr module Print class Form def initialize(form, code) @template = Template.get(form) || raise("Unable to find template for #{form}") @record = @template.model.where(hash_code: code).first! @latex = @template.path_for_record(@record) unless @latex.exist? raise("Unable to find template type for record") end Lanes.logger.debug "Printing #{form} #{code} using #{@latex}" end def as_pdf begin template.to_stringio rescue => e Lanes.logger.warn e.log raise end end def as_latex template.compile_latex end def data vars = { @template.name.underscore => @record, 'root_path' => ::Skr::Print::ROOT } if @record.respond_to?(:latex_template_variables) vars.merge!(@record.latex_template_variables) end vars end def template ErbLatex::Template.new( @latex, data: data, context: Skr::Print::Context, layout: ROOT.join('layout.tex.erb'), partials_path: ROOT.join('partials'), packages_path: ROOT.join('packages') ) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stockor-0.4.0 | lib/skr/print/form.rb |