Sha256: ce2f1cf960d2e4f05d7f7b06e91da8df9d6f1fadf79166b679ec7a44c328ec2c
Contents?: true
Size: 1.52 KB
Versions: 7
Compression:
Stored size: 1.52 KB
Contents
require "active_support/concern" module Renalware module Concerns module PdfRenderable extend ActiveSupport::Concern included do def default_pdf_options { page_size: "A4", layout: "renalware/layouts/pdf", disposition: "inline", footer: { font_size: 8, right: "Page [page] of [topage]" }, show_as_html: Rails.env.development? && params.key?(:debug) } end # Render a Liquid template loaded from the database. # The template may have variable place holders w.g. {{ patient.name }} and these # are resolved by passing instance of Liquid Drops (presenters) in the variables hash. def render_liquid_template_to_pdf(template_name:, filename:, variables: nil) variables ||= default_liquid_variables body = System::RenderLiquidTemplate.call(template_name: template_name, variables: variables) options = default_pdf_options.merge!(pdf: filename, locals: { body: body }) render options end private # By default if no variables supplied, we insert the patient drop to allow basic patient # data to be accessed in the template with eg {{ patient.name }} # Note the has key must be a string and not a symbol. def default_liquid_variables { "patient" => Patients::PatientDrop.new(patient) } end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems