Class: Proforma::Template

Inherits:
Prototype show all
Includes:
Compiling::Compilable
Defined in:
lib/proforma/template.rb

Overview

A Template instance is a set of modeling objects with directions on how to compile it into a Prototype object. The prototype instance can then be rendered into an end-result such as a text, pdf, or spreadsheet file.

Instance Attribute Summary collapse

Attributes inherited from Prototype

#children, #title

Instance Method Summary collapse

Constructor Details

#initialize(children: [], split: false, title: '') ⇒ Template

Returns a new instance of Template.



20
21
22
23
24
# File 'lib/proforma/template.rb', line 20

def initialize(children: [], split: false, title: '')
  @split = split

  super(children: children, title: title)
end

Instance Attribute Details

#splitObject Also known as: split?



26
27
28
# File 'lib/proforma/template.rb', line 26

def split
  @split || false
end

Instance Method Details

#compile(data, evaluator) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/proforma/template.rb', line 31

def compile(data, evaluator)
  if split?
    compile_record(data, evaluator)
  else
    compile_collection(data, evaluator)
  end
end