Understanding Document Templates | MergeOS

Understanding Document Templates

Learn how Document Templates are used to create the final documents produced by MergeOS.

Document Templates are standard Word documents that you use to design your template. When MergeOS processes a row of data, it uses this template to generate one document. You can use all the MS Word features to style and layout your Document Template, and use simple placeholder variables to tell MergeOS where to insert the data. You can read more about data and how to set it up in the Understanding Datatables article.


Fundamentals

Many businesses use MS Word to create client letters, invoices and reports. A common practice is to create a master template document that contains the text, and then use placeholder text to show what needs to be replaced (e.g. <insert name here>). Someone then goes through and manually replaces the placeholder text before sending it out to the recipient. More advanced users might use the standard Word mail merge feature. MergeOS takes this same concept but adds some more powerful features. This page will show how you create Document Templates.


Placeholder Variables & Functions

There are a few places that MergeOS can source the data that we use to merge into a Document Template. All of these sources are configured within a Project. They are:

  • Columns from the projects Data Table
  • Output Named Ranges, Tables and Charts from a Pre-process template
  • Files from your Miscellaneous files folder
  • MergeOS System variables
  • Your Organisation variables
  • Project variables
You place variables into your Document Templates within double curly braces {{ }} to differentiate them from the standard text. Some variables require the use of a function when being inserted. The function allow you to pass through more information, such as a date format or the size of an image.

Data Table Variables

Use Data Table variables to insert values from a Data Table into your documents. Columns from the data table can be inserted by using the column name.

An example Data Table with 5 columns


{{ ["Client ID"] }}
{{ ["First Name"] }}
{{ ["Last Name"] }}
The variables above would insert the following when the first row is merged into the document

1
Missy
Coucher


Pre-process Variables

Pre-process variables come from an Excel spreadsheet configured in the pre-process step of a project. 

Output Named Ranges

Use Output Named Ranges to insert values from a pre-process spreadsheet into your documents. 

{{ ["pre"."variable_name"] }}
Variables from pre-process templates must start with "pre".
image.png 44.46 KB
{{ ["pre"."full_name"] }}
The variable above would insert the following:

Missy Coucher

Chart & Graph variables

Use the Chart function and the name of a chart in the Excel pre-process template to insert charts into your documents.

{{ chart(["pre"."chart_name"]) }}
{{ chart(["pre"."chart_name"], width="500", height="500") }}
Parameters
  • width: The maximum width of the chart. Optional, though required if height is set.
  • height: The maximum height of the chart. Optional, though required if width is set.
  • preserve-ratio: True or False. If true, the chart will keep the same width to height ratio when resized. If false, the width and height will be set to the exact values. This may warp the chart.

Example
A chart in an Excel pre-process template

Excel Table Variables

Use the Table function with the name of an Excel Table to insert a formatted Word table into your document.

{{ table(["pre"."table_name"]) }}

{{ table( ["pre"."table_name"], 
            style="ReportJazz", 
            header-row="true", 
            first-column="true", 
            total-row="false", 
            last-column="false", 
            banded-rows="true", 
            banded-columns="false", 
            align-decimals="right") }}

Parameters
All parameters are optional. 

  • style: Sets the style of the table using one of the table styles in the Word Document Template. You can create your own styles, name it and use that name here too. If not set, the default Word Table Grid is used.
  • header-row: True or False. Set to true to display special formatting for the first row of the table.
  • first-column: True or False. Set to true to display special formatting for the first column of the table.
  • total-row: True or False. Set to true to display special formatting for the last row of the table.
  • last-column: True or False. Set to true to display special formatting for the last column of the table.
  • banded-rows: True or False. Set to true to display banded rows, in which each even rows are formatted differently from odd rows.
  • banded-columns: True or False. Set to true to display banded rows, in which each even columns are formatted differently from odd columns.
  • align-decimals: True or False. Set to true to right-align numbers in their column.

File Variables

Use the Image function to insert images that you have previously uploaded to your MergeOS account.

{{ image["image_reference_name"] }}

{{ image(["image_reference_name"], width="100", height="100", preserve-ratio="false") }}

Parameters
  • width: Number. The maximum width of the image. Optional, though required if height is set.
  • height: Number. The maximum height of the image. Optional, though required if width is set.
  • preserve-ratio: True or False. If true, the image will keep the same width to height ratio when resized. If false, the width and height will be set to the exact values. This may warp the image.

Uploading Images and setting the Image Reference Names
You can upload images to use in your templates to the Miscellaneous Files folder in your account.

Navigate to the Miscellaneous Files folder
  1. Click on the Folders menu item in the left menu
  2. Click on the Miscellaneous Files folder

Upload an image
  1. Click on Upload File and choose an image from your computer
  2. Click on the Image to enter the image details page

Editing the Reference Name of an image
  1. Click into the Reference Name text box and enter a new name
  2. Click on the Save button
You can now use that Image in your documents with the image function as described above.


Other Variables

There are some other variables you can use in your Document Templates that come from the system. These are outlined below.

System Variables




More Articles