Skip to main content

What syntax can I use in a custom print template?

Custom print templates use curly-brace placeholders to fill in answers, show or hide content, repeat rows, add images and do sums.

Custom print templates use curly-brace placeholders to fill in answers, show or hide content, repeat rows, add images and do sums.

This is the full reference for the placeholders you can put in a Word, Excel or PowerPoint print template. If you're new to custom print templates, start with the getting started article under Related articles, then come back here when you need the detail.

Which files can I use, and where do placeholders work?

Custom print templates can be Word (.docx), Excel (.xlsx) or PowerPoint (.pptx) files, up to 25 MB. Fillable PDF forms and HTML templates aren't supported. If your template is a fillable PDF, rebuild it as a .docx.

File type

Where placeholders are filled in

What isn't filled in

Word (.docx)

The document body, tables (including nested tables), headers, footers and text boxes

Comments and document properties

Excel (.xlsx)

Cells on every worksheet

Sheet tab names, print headers and footers, and cell comments

PowerPoint (.pptx)

Slides, tables, text boxes, speaker notes, and chart titles and text

Slide masters and slide layouts

How do placeholders work?

Placeholders use curly braces. Here are three examples:

{$customer_name} {$invoice.total|currency} {if $approved}Approved{/if}

A few rules decide what counts as a placeholder:

  • A placeholder starts with { followed straight away by a character that isn't a space, and ends at the matching }.

  • { followed by a space, tab or new line (such as { note }), or a { with no matching }, is treated as ordinary text.

  • A } inside single or double quotes doesn't end the placeholder, for example {$status|default:"{none}"}.

  • An empty {} prints as {}.

Print curly braces as text

To show curly-brace syntax in the finished document without filling it in, wrap it in {literal} and {/literal}:

{literal}{$this_prints_as_text}{/literal}

The {literal} and {/literal} markers are removed and everything between them prints as typed. If {literal} has no matching {/literal}, it isn't treated as a literal block and placeholders are filled in as normal.

What happens when a placeholder is wrong

A bad placeholder never stops a document from printing. Instead:

  • Missing data: a valid placeholder for a field that isn't in the data prints empty.

  • Unreadable placeholders: a placeholder with no $ (such as {customer_name}), an unknown modifier, an invalid modifier argument, an unreadable number, or an unbalanced {if} or {foreach} prints exactly as it's written in the template.

  • Unreadable conditions: an {if}, {elseif} or {tableif} condition that can't be read counts as false. Its text is skipped and any {else} text prints instead.

  • Lists and groups printed directly: printing a list or group on its own ({$items}) prints empty. Use a loop to show its items.

  • Raw image data: printing image data without insert_image or image prints empty.

  • Invalid characters: control characters that Office files can't hold are removed automatically, so the file always opens.

What Word changes as you type

Word changes some characters as you type. The print engine handles the most common ones:

  • Smart (curly) quotes: curly quotes that open or close text inside a placeholder are read as straight quotes, so {$date|date_format:“%d/%m/%Y”} works. Quotes inside the text stay as typed, and text comparisons treat straight and curly quotes as equal.

  • Dashes: en dashes, em dashes and minus signs outside quoted text are read as -, so {$end – $start} works. Inside quotes they print as typed.

  • Spaces after the dollar sign: {$ signature|insert_image:100:50} is read as {$signature|insert_image:100:50}. A space after the opening brace ({ $signature}) still makes it ordinary text, and a line break after $ isn't folded.

  • Non-breaking spaces: in {if} conditions they separate words like regular spaces.

  • Multi-line answers: line breaks in an answer become real line breaks in Word.

Even so, turn off smart quotes before you edit a template. See What are the best habits for reliable templates? below.

How do I print an answer, and how do I reach nested answers?

Every placeholder for data starts with $:

{$job_number} {$client.name} {$line_items[0].description} {$line_items.0.description}

In your own templates, copy the real placeholders from the form's Custom Printing tab. The examples in this article use made-up names such as {$hours}.

Naming rules

  • Names start with a letter or underscore, followed by letters, digits or underscores.

  • Hyphenated names are supported ({$textarea-6c5}), as long as a part doesn't end with - or contain --. See How do I do calculations? for how hyphens work with maths.

  • Names are case-sensitive. {$Name} and {$name} are different.

Reaching answers inside groups and lists

How

Example

What it reads

Dot

{$client.address.city}

The city inside the address inside the client

Bracket number

{$crew[0].name}

Item 0 of a list (the first item)

Dot number

{$crew.0.name}

The same as the line above

Quoted bracket

{$order['po-num']}

A name with hyphens, spaces or punctuation, such as {$order["Part #"]}

Name stored in a variable

{$prices[$item_code]}

The entry whose name is stored in $item_code

Character of text

{$code[0]}

The first character of a piece of text

  • A whole number in quotes ($items['1']) is read as item 1. A zero-padded number in quotes ($items['01']) stays the text name "01".

  • Double-quoted bracket names accept escape sequences such as \t but not variables inside the text.

  • A name stored in a variable only accepts a plain variable ($map[$key], $grid[$r][$c]). Maths inside the brackets, like $items[$i + 1], isn't supported. Work the number out first: {$next = $i + 1}{$items[$next]}.

How values print

Type of value

What prints

Text

The text as it is

Whole number

The exact number (up to 64-bit)

Decimal number

Up to 14 significant digits. Very large or very small numbers use scientific notation, such as 1.0E+21

True

1

False

Nothing

Blank or missing

Nothing

List or group

Nothing. Use a loop to show the items

How do I use text, quotes and special characters?

Single quotes

Text in single quotes is used exactly as typed. There are no escape sequences and no variables inside it:

{$code|default:'N/A'} {$label|cat:' costs $5'}

Double quotes

Text in double quotes can contain escape sequences and values from your data:

Type

Result

\n

New line

\t

Tab

\r

Carriage return

\\

A backslash

\"

A double quote

\$

A dollar sign (stops the value being filled in)

\v \f \e

Vertical tab, form feed, escape (control characters that Office files can't hold are removed when the file is made)

\101 \x41

A character by its code, in octal (1 to 3 digits) or hex (1 to 2 digits). Back-to-back codes are read as UTF-8, so "\xc3\xa9" prints as é

You can put values inside double-quoted text in three ways:

{"Hello $first_name"} {"Total: {$row.amount} units"} {"`$work_hours + $travel_hours` hours"} {$hours|cat:" of $planned hours"}
  • $name reads only the bare name. "$a.b" prints the value of $a followed by the text .b, and "$number-915" prints the value of $number followed by -915.

  • {$expression} works out a full path or calculation, including hyphenated names: "{$number-915}", "{$row.worker}", "{$qty * $rate}". Inside a modifier argument it must be a plain variable path, not a calculation.

  • Backticks around an expression that starts with $ work in standalone text, but not inside modifier arguments.

Don't put an unescaped double quote, or a placeholder that isn't a value (such as {/if}), inside the braces or backticks in double-quoted text.

Numbers and fixed words

  • Numbers: whole numbers (42, -10), decimals (7.5) and whole-number exponents (1e3, 2E5).

  • Avoid leading zeros on whole numbers. 010 is read as octal 8, and 08 or 09 can't be read.

  • These number styles can't be read: 1e+5, 1e-5, 1.5e3, 1_000, 0x10 and 1e. The placeholder prints as written, or the condition counts as false. Write the number out in full, or use 1e5.

  • Fixed words: true, false and null (not case-sensitive).

  • Empty list: [], in modifier arguments only, as in {count($items|default:[])}.

How do I do calculations?

Maths inside a placeholder

Use +, -, *, /, % (remainder), a leading + or -, and brackets directly in placeholders, conditions and assignments:

{$work_hours + $travel_hours} hours {($quantity * $unit_price)|number_format:2} {$total / $days} {if $work_hours + $travel_hours > 8}Overtime{/if}

How values are read in a calculation:

  • Numbers and numbers in text calculate directly: "7.5" + 1 is 8.5.

  • Text that starts with a number uses that number: "7.5 hours" + 1 is 8.5.

  • Blank, missing, null or non-numeric text counts as 0 and printing carries on.

  • True is 1 and false is 0.

  • A list or group in a calculation fails. The placeholder prints as written, or the {if} counts as false.

  • Dividing by zero, or taking a remainder by zero, gives no value. A print placeholder prints empty, an assignment is set to null and an {if} counts as false. % cuts both numbers to whole numbers first, so % 0.5 divides by zero.

  • A division such as {$a / 3} can print up to 14 digits (0.66666666666667). Format money and totals with |number_format:2, |currency or |round:2.

Subtracting and hyphenated names

Some answer names contain hyphens (such as number-915), so the print engine decides what a hyphen means when it prints:

  • A - followed by a letter ({$worker-time}) is always part of the name.

  • A - straight after a name and followed by a digit ({$qty-2}) checks your data. If the full hyphenated name (qty-2) exists, it reads that. If not, and qty exists, it subtracts. If neither exists, it prints empty.

  • A - straight after a missing name and followed by $ or a space gives no value (empty, or false in {if}).

Always put a space on both sides of the minus sign: {$qty - 2} and {$end - $start}, never {$qty-2} or {$end-$start}.

Order of operations

From first to last:

  • Modifiers (|modifier:argument) apply to the single value just before the |.

  • Leading !, not, - and +.

  • *, / and %.

  • + and -.

  • Joining text: a final |cat and double-quoted text with values in it.

  • Comparisons: <, >, <=, >= and the word forms. They can't be chained.

  • Equality: ==, !=, ===, !== and the word forms. They can't be chained.

  • && and and.

  • || and or.

Because a modifier applies only to the value just before it, this formats only the rate and then multiplies:

{$quantity * $rate|number_format:2}

Put the calculation in brackets instead:

{($quantity * $rate)|number_format:2}
  • An operator after a modifier argument ends the argument. {$hours|round:2 - 8} works out round($hours, 2) - 8.

  • When |cat is the last modifier, it joins after the calculation. {$work + $travel|cat:" hours"} adds first and prints "9.5 hours".

  • A placeholder can hold up to 512 pieces and brackets nested 32 deep.

Store a value and keep running totals

Any of these three forms stores a value. Storing a value prints nothing:

{$total = 0} {assign var="total" value=0} {assign "total" 0}

The name can be quoted or bare, and must use only letters, digits and underscores, starting with a letter or underscore. No hyphens.

Stored values are shared across the whole document, and last outside {if} and {foreach} blocks, so you can build a running total:

{$total = 0} {foreach $lines as $row}   {$row.item}: {($row.qty * $row.rate)|number_format:2}   {$total = $total + ($row.qty * $row.rate)} {/foreach} Grand Total: {$total|currency}
  • On the first pass, a total that hasn't been set counts as 0. Setting it to 0 first is clearer.

  • Setting the loop's own item or key variable ({$row = ...}) changes it for the rest of that pass.

  • Reading order: a value set earlier is available later. In Word the order is headers, then the body, then footers, so a footer can show a total built in the body but a header can't. Excel goes through worksheets in tab order, row by row. PowerPoint goes through slides in order.

  • Don't store an image address in a variable and pass it to |insert_image. Use |insert_image directly on an answer or loop variable.

The math tag

{math} works out an equation written as text, with each name in the equation set by an attribute:

{math equation="(x + y) * z" x=$work_hours y=$travel_hours z=$rate format="%.2f"} {math equation="round(x / y, 2)" x=$cost y=$units assign="unit_cost"}

Attribute

What it does

equation

Required. The equation, up to 1,000 characters not counting spaces

name=value

One for each name used in the equation

format

Optional. A format such as "%.2f", using the same codes as string_format

assign

Optional. Stores the result under this name instead of printing it

In the equation you can use +, -, *, /, %, brackets, and ^. The ^ is not a power sign. Use pow(x, y) for powers.

Type

Functions

Rounding and basic

abs(x), ceil(x), floor(x), round(x[, precision[, mode]]), sqrt(x), pow(base, exp)

Logs and exponents

exp(x), log(x[, base]), log10(x)

Largest and smallest

max(a, b, ...), min(a, b, ...) with 2 or more values

Constants and angles

pi(), deg2rad(x), rad2deg(x)

Trigonometry

sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh

  • Inputs must be plain numbers. Every value must be only digits with an optional decimal point, sign and spaces. A blank value or text such as "5 hours" makes {math} print nothing. Use maths inside a placeholder ({$a + $b}) when an answer can be blank or have units.

  • Not supported: int(), rand() and srand() print the placeholder as written. Use floor() or round() instead of int().

  • Not allowed in the equation: mod, **, ?:, --, ++ and a minus sign directly before a name. Write y - x or 0 - x + y instead of -x + y. A minus before a plain number (-5) is fine.

  • Errors: a missing equation, unknown name, unbalanced brackets, illegal characters or an invalid format print nothing. Mistakes such as 2(3), or max(x) with only one value, print the placeholder as written.

  • Use maths inside a placeholder for everyday sums. Keep {math} for functions like sqrt(), pow(), ceil(), floor(), min(), max() and trigonometry.

How do I show or hide content with a condition?

Use {if} to show or hide text, paragraphs or table rows based on an answer:

{if $hours > 8}   Overtime ({$hours} hrs) {elseif $hours > 0}   Standard ({$hours} hrs) {else}   No hours recorded {/if}

Comparison words and symbols

Symbol

Word

Meaning

==

eq

Equal

!=

ne, neq

Not equal

===

None

Identical (same type and same value)

!==

None

Not identical

>

gt

Greater than

<

lt

Less than

>=

gte, ge

Greater than or equal

<=

lte, le

Less than or equal

&&

and

Both are true

||

or

Either is true

!

not

Not true

Word forms are lowercase (eq, and, not). Comparisons can't be chained. Write {if $a > 0 && $a < 10}, not {if 0 < $a < 10}.

When an answer counts as true or false

When you test an answer on its own, as in {if $field}:

  • False: a missing answer, null, false, 0, 0.0, empty text, "0", an empty list and an empty group.

  • True: everything else, including "false", "no", "0.0", a single space, and any list or group that isn't empty.

How comparisons work

  • Text with text: case-sensitive, so "Open" == "open" is false. Use |lower to ignore case: {if $status|lower == "open"}. Straight and curly quotes and apostrophes compare as equal.

  • If both pieces of text are plain numbers (spaces around them are fine), they compare as numbers: "10" > "9" is true. If either isn't a plain number, they compare alphabetically: "10 hours" > "8" is false, because "1" comes before "8".

  • A number with text: with >, <, >= and <=, the text is read as its leading number, or 0 if it has none. {if $hours > 8} is true for "10 hours" and false for "n/a" and blank.

  • With == and !=, text that isn't a number never equals a number. {if $hours == 0} is false for "n/a" and blank, and true for "0".

  • Identical (=== and !==): type and value must both match. 1 === "1" is false.

  • Modifiers work anywhere in a condition: {if $status|trim|lower == "approved"}, {if $items|@count > 0}.

Functions you can use

These eight functions work in conditions, print placeholders, calculations and assignments. They take one value and aren't case-sensitive:

Function

What it does

Example

empty(x)

True if x is missing, null, false, 0, 0.0, empty text, "0", an empty list or an empty group

{if !empty($notes)}...{/if}

isset($var)

True if the answer exists and isn't null. It must be a variable

{if isset($discount)}...{/if}

count(x), sizeof(x)

Number of items in a list or group. 0 for null, missing or blank. 1 for other single values

{if count($crew) > 0}...{/if}

is_array(x)

True for lists and groups, false for single values or null

{if is_array($tags)}...{/if}

is_numeric(x)

True for numbers and text that is a number (spaces around it are fine)

{if is_numeric($qty)}...{/if}

strlen(x)

Length of text in bytes (a tick mark is 3). Empty for lists and groups

{if strlen($code) == 6}...{/if}

trim(x)

Removes spaces, tabs and line breaks from both ends. Empty for lists and groups

{if trim($notes) != ""}...{/if}

Modifiers work inside and after functions:

{count($items|default:[])} {count($items) + 1} {trim($name)|upper}

Any other function, or a second value passed to one of these, isn't supported. In a condition it makes the condition unreadable, so it counts as false. In a print placeholder it prints as written.

How a condition removes content in Word

In Word, an {if} can run across several paragraphs, table cells or table rows, and can sit in the middle of a line of text.

  • A losing branch removes everything between its placeholder and the next branch or closing placeholder, in reading order. Text outside the placeholders stays.

  • Table cells in a removed branch are emptied, not deleted, so the columns stay lined up. That makes tick-box grids possible: put {if $answer == "Yes"}✓ in the Yes cell and {else}✓{/if} in the No cell.

  • A paragraph left completely empty is deleted. A table row where every cell is empty is deleted. A table with no rows left is deleted.

  • Pictures, drawings, text boxes, icons, symbols, page and section breaks, equations and fields (such as page numbers) count as content and are kept. Bookmarks, comments and fields that a removed branch cuts across stay intact.

Hide a whole table row with tableif

{tableif} works like {if}, except that in a Word table, a false {tableif} removes the entire row, even when other cells in the row hold labels:

{tableif !empty($notes)}Notes: {$notes}{/tableif}

If you leave out {/tableif} in Word, it closes by itself at the earliest of:

  • the end of its table row (inside a table) or the end of its paragraph (outside a table)

  • an {else}, {elseif} or {/if} that belongs to an {if} around it

  • the {/foreach}, {foreachelse} or {/tablerow} of a loop around it

A {tableif} with its own {/tableif} can have its own {elseif} and {else}. Always writing {/tableif} is clearer.

Conditions in Excel and PowerPoint

  • Excel: keep the whole {if}...{/if} in one cell. An {if} across several cells prints as written.

  • PowerPoint: keep the whole {if}...{/if} in one piece of text with the same font and style. An {if} across paragraphs, shapes or differently formatted text prints as written.

  • {tableif} doesn't remove rows in Excel or slides in PowerPoint. Use {if} inside single cells or pieces of text.

How do I repeat rows, lines or paragraphs?

Use {foreach} or {tablerow} to repeat content for every item in a list, such as a crew list or the rows of a repeating question group. Both accept two forms.

Short form:

{foreach $crew as $row}   {$row.name} - {$row.role} {foreachelse}   No crew recorded {/foreach}

Short form with a key:

{foreach $crew as $key => $row}   {$key}: {$row.name} {/foreach}

Long form (quotes around item and key are optional):

{foreach from=$crew item=row key=k}   {$k}: {$row.name} {/foreach}

What a loop goes through

  • Lists: each item in order. The key is 0, 1, 2 and so on.

  • Groups: each property. The key is the property name and the row is its value.

  • A single value that isn't empty (such as "abc", 0 or false): the loop runs once, with key 0.

  • Missing, null, empty text, an empty list or an empty group: the loop runs zero times and shows the {foreachelse} text if there is any.

Item and key names must use only letters, digits and underscores. No hyphens.

Position in the loop

Inside a loop, add @index, @iteration, @first or @last to the item name:

Placeholder

Value

{$row@index}

Position starting at 0 (0, 1, 2 and so on)

{$row@iteration}

Position starting at 1 (1, 2, 3 and so on)

{$row@first}

True (1) on the first item, otherwise empty

{$row@last}

True (1) on the last item, otherwise empty

For example, a comma-separated list:

{foreach $tags as $tag}{$tag}{if !$tag@last}, {/if}{/foreach}

Sort the list

Add a modifier straight to the list to sort it:

{foreach $crew|sort:"name" as $row}   {$row.name} {/foreach}{foreach $crew|multisort:"role":"asc":"name":"asc" as $row}   {$row.role}: {$row.name} {/foreach}

If you use a modifier that doesn't exist on a list, the loop is empty and shows the {foreachelse} text.

Loops inside loops, and values after a loop

  • Loops can be nested in Word, and inside a single cell in Excel or a single piece of text in PowerPoint. An inner loop can use the outer loop's variables and position values.

  • After a loop, its item and key names keep the last value if they didn't exist before the loop. If they did exist, the earlier value comes back.

Loops in Word

What you want

Where to put the placeholders

Repeat a table row with several cells

Put {foreach $rows as $row} in the first cell and {/foreach} in the last cell. To repeat a block of rows, put them in cells across the rows.

Repeat a table row with one cell

Use {tablerow $rows as $row}...{/tablerow} instead of {foreach}. In a table row, {tablerow} repeats the whole row even when both placeholders are in one cell.

Repeat paragraphs inside one table cell without adding rows

Put both {foreach} and {/foreach} inside that cell. An empty loop leaves one blank paragraph.

Repeat whole paragraphs outside a table

Put {foreach} in a paragraph before the content and {/foreach} in a paragraph after it. Tables, pictures and text boxes in between repeat for each item.

Repeat text on one line

Put {foreach} and {/foreach} on the same line. This repeats text, tabs, line breaks and symbols, but not pictures or text boxes. Wrap whole paragraphs or table rows to repeat those.

Nested tables

Put both placeholders inside the inner table to repeat inner rows, or across the outer cells to repeat the outer row.

Text boxes

Both placeholders must be inside the same text box, or both outside. A loop that crosses a text box edge prints as written.

  • Loops back to back on one line ({/foreach}{foreach $plant as $p}) are split automatically, so each loop repeats its own lines.

  • A tablerow with no closing placeholder: inside a table row it closes at the end of the row and repeats the row for each item. Several of these in one row over the same list and item become one row loop. Outside a table row, it closes right after the last placeholder that uses its item, so labels after it print once.

  • A closed tablerow in one cell of a table row repeats the whole row, even if static text sits outside the closing placeholder in that row. Every tablerow in the row must use the same list, item and key, and not sit inside an {if} or an outer loop that was opened in that row.

Loops in Excel

  • Row loops: put {foreach $rows as $row} in a cell on row N and {/foreach} in a cell on row M, on the same worksheet and with M the same as or below N. Rows N to M repeat for each item. {foreachelse} works.

  • A tablerow with no closing placeholder closes at the end of its spreadsheet row and repeats that row for each item. Several over the same list in one row act as one loop. One over a different list closes in its own cell.

  • The sheet updates itself when rows grow. Formulas on the same sheet and other sheets, and charts, shift and expand (=SUM(E5:E5) grows to cover every repeated row). Merged cells in the repeated rows are copied each time and merged cells below move down. Hyperlinks, conditional formatting, data validation, filters, Excel tables, drawings, row page breaks, defined names and pivot sources are all adjusted.

  • Numbers become real numbers. A cell whose result is a plain number (such as 42 or -12.50) is saved as a number, not text, and the workbook recalculates when opened, so formulas like SUM work before the PDF is made.

Limits in Excel:

  • A loop inside a repeated band of rows must open and close inside a single cell.

  • Start each row loop on its own row. Two loops can't share a row.

  • Opening and closing placeholders must be on the same worksheet.

Loops in PowerPoint

  • Table rows: put {foreach} in a cell of row N and {/foreach} in row M of the same table. Rows N to M repeat for each item and the table grows or shrinks to fit.

  • Paragraphs: put {foreach} and {/foreach} in different paragraphs of the same text box or table cell. Paragraphs that hold only a loop placeholder are removed, so they leave no blank lines.

  • On one line: put {foreach} and {/foreach} in the same piece of text with the same formatting.

Limits in PowerPoint:

  • Loops can't add or remove slides.

  • A loop can't cross between shapes, tables, text boxes or slides.

  • A loop inside a repeated table row or paragraph must stay within one piece of text.

  • Two loops can't share a row or paragraph.

  • A loop on one line that is split across differently formatted text prints as written. Use the same formatting for the whole loop, or put its placeholders on separate lines.

  • A tablerow with no closing placeholder doesn't close by itself in PowerPoint. Always write {/tablerow} or {/foreach}.

How do I add photos and signatures?

For the basics, see How do I add images to a custom print on the dashboard?. This section covers the details.

Where an image can come from

  • A public https:// address. Private and internal network addresses are rejected. Each image has 5 seconds to load and can be up to 10 MB.

  • Image data that starts with data:image/ (PNG, JPEG, GIF, WebP and others).

  • Phone photos that carry rotation information are turned upright automatically.

If an image answer is blank, nothing prints and there's no error. If an address isn't blank but the image can't be loaded or is rejected, the placeholder is cleared rather than printed as text.

Set the size with insert_image

Use {$source|insert_image:width:height}. Sizes are in pixels at 96 pixels per inch. They can be numbers or variables, such as {$img|insert_image:$w:0}.

Placeholder

Size you get

{$sig|insert_image:200:80}

Exactly 200 by 80 pixels. It doesn't keep the shape of the picture, so it stretches to fit.

{$photo|insert_image:300:0}

300 pixels wide, with the height worked out from the picture. Best for photos.

{$photo|insert_image:0:150}

150 pixels tall, with the width worked out from the picture.

{$photo|insert_image}

The picture's own size. In Word it shrinks, never grows, to fit the text area of the page. In Excel and PowerPoint it uses the picture's own size.

  • Word: the picture is placed in the line at the placeholder. To repeat pictures in a loop, put the loop around whole paragraphs or table rows, not on one line.

  • Excel: the picture is anchored to the cell and the row grows to fit it.

  • PowerPoint: the picture goes at the top-left corner of the shape that holds the placeholder. Several pictures in one shape stack down.

  • insert_image can't be used inside a calculation. Use it on an answer. Modifiers before it are fine: {$logo|default:$fallback_logo|insert_image:200:0}.

Fit a picture to its cell or shape with image

{$photo|image:1:png}
  • Excel: the picture fills the cell or the merged cells.

  • PowerPoint: the picture fills the shape.

  • Word: the picture goes in at its own size, shrunk to fit the text area (the same as insert_image:0:0).

Format words such as png or jpg don't need quotes.

Which modifiers can I use?

A modifier changes a value. Add it after a | with arguments after colons:

{$name|trim|upper|truncate:20}

{$docket_no|pad:5:"0"}

{$first|cat:" ":$last}

  • Modifier names are case-sensitive. {$name|upper} works. {$name|Upper} isn't recognised and prints as written.

  • Modifiers run left to right. Each one uses the result of the one before.

  • A @ before the name works the same: |@count is the same as |count.

  • Arguments can be text in single or double quotes, numbers, true or false, [] and variables.

  • A modifier that isn't in the lists below prints the whole placeholder as written.

Text

Modifier

Arguments

What it does

upper

None

Changes all text to capitals

lower

None

Changes all text to lower case

ucfirst

None

Capitalises the first character (English letters a to z)

ucwords

None

Capitalises the first English letter after each space

capitalize

uc_digits=false, lc_rest=false

Capitalises words. uc_digits=true also capitalises words that contain digits. lc_rest=true lower-cases the rest of each word

trim

charlist (optional)

Removes spaces from both ends, or the characters in charlist. Ranges work, such as "0..9" or "a..z"

strip

replacement=" "

Turns runs of spaces, tabs and new lines into replacement

truncate

length=80, etc="...", break_words=false, middle=false

Shortens text to length characters, including etc. Cuts at word ends unless break_words is true. middle=true cuts from the middle. A length of 0 prints nothing

wordwrap

width=80, break="\n", cut=false

Wraps lines at width characters. Longer words stay whole unless cut is true

indent

chars=4, fill=" "

Adds fill, repeated chars times, to the start of every line

cat

values

Adds one or more pieces of text or values to the end

replace

search, replace=""

Finds and replaces text everywhere it appears

regex_replace

search, replace=""

Replaces using a pattern such as /[^0-9]/ (flags i, m, s, u, y; always global). A pattern that isn't valid leaves the text unchanged

substr

start, length (optional)

Takes part of the text. A negative start or length counts from the end

spacify

spacer=" "

Puts spacer between every character (ABC becomes A-B-C)

default

fallbacks

Gives the first fallback that isn't empty, only when the value is missing, null or empty text. It doesn't act on 0, "0" or false

nl2br

xhtml=true

Adds <br /> before line breaks. Rarely needed, because new lines already print as line breaks in Office files

escape

type="html", charset="", double_encode=true

Encodes text. Types: html, htmlall, url, urlpathinfo, quotes, hex, hexentity, decentity, javascript, mail, nonstd. An unknown type leaves the text unchanged

unescape

type="html"

Decodes text. Types: html, htmlall, entity, url

strip_tags

replace_with_space=true

Removes HTML tags, replacing each with a space unless you pass false

count_characters

include_spaces=false

Counts characters, leaving out spaces unless you pass true

count_words

None

Counts words

count_sentences

None

Counts sentences that end in . ? or !

count_paragraphs

None

Counts paragraphs separated by new lines

Examples: {$notes|truncate:40:"…"}, {$co|replace:"Inc":"Pty Ltd"}, {$id|regex_replace:"/[^0-9]/":""}, {$id|substr:-4}, {$nick|default:"Not provided"}.

Numbers and money

Modifier

Arguments

What it does

number_format

decimals=0, dec_point=".", thousands=","

Formats a number, rounding half away from zero. Blank or null prints 0 (0.00 with 2 decimals). "12 hours" prints 12. Text that isn't a number prints nothing

currency

Same as number_format, with 2 decimals

Formats as $1,234.50, and negatives as -$1,234.50. It always uses $. Pass arguments to change decimals or separators, such as currency:0

round

precision=0, mode=1

Rounds a number. Mode 1 is half away from zero, 2 is half down, 3 is half to even and 4 is half to odd. Blank or text counts as 0

pad

width, pad=" "

Adds pad to the left until the text is width characters (42 becomes 00042). Does nothing if it's already long enough

phone_format

pattern="(%3) %3-%4"

Takes out everything but digits and fills each %N with the next N digits (0298765432 becomes 02 9876 5432). If there aren't enough digits, the original is left unchanged

string_format

format

Formats one value like sprintf: %s, %d, %u, %f, %F, %e, %E, %g, %G, %h, %H, %c, %o, %x, %X and %b, with width, precision, alignment, sign and padding. Use %% for a literal %

Examples: {$amount|number_format:2:",":"."}, {$docket_no|pad:5:"0"}, {$qty|string_format:"%04d"}, {$pct|string_format:"%.1f%%"}.

Dates and times

Modifier

Arguments

What it does

date_format

format="%b %e, %Y", default_date (optional)

Formats a date and time. See the dates section below

strtotime

baseTimestamp (optional)

Turns a date or time into Unix seconds, for working out durations. Dates that can't be read print nothing and count as 0 in calculations. baseTimestamp sets the reference day for standalone times and relative words

age

None

Whole years from a date to today. A future date gives 0. A missing or unreadable date prints nothing

Ticks

Modifier

Example

What it does

checkbox

{$ppe_ok|checkbox}

Prints ☑ if true and ☐ if false

checkmark

{$ppe_ok|checkmark}

Prints ✓ if true and nothing if false

Lists

Modifier

Arguments

What it does

sort

field (optional), dir="asc"

Sorts a list, keeping equal items in order, by a field if you name one, ascending (asc) or descending (desc). Numbers sort as numbers. Null and missing go last. Anything that isn't a list is left unchanged

multisort

field1:dir1:field2:dir2

Sorts by several fields. Anything that isn't a list is left unchanged

count

None

Number of items in a list or group. 0 for null or missing, 1 for any single value including empty text. Use the count($crew) function when an empty list might arrive as empty text

Images

Modifier

Arguments

What it does

insert_image

widthPx=0, heightPx=0

Adds a picture at a pixel size. 0 keeps the picture's shape. See the photos section above

image

index, format

Fits a picture to its cell (Excel), shape (PowerPoint) or page area (Word). See the photos section above

How do I print dates and times?

Use date_format to print a date, and strtotime to work with times:

{$date|date_format:"%d/%m/%Y"} {$date|date_format:"j M Y":"now"}

Dates and times it can read

  • ISO dates, with or without seconds or a time zone: 2026-11-09, 2026-11-09 07:30, 2026-11-09T07:30:00Z, 2026-11-09T07:30+10:00. A date with no time zone is read in the time zone used for printing.

  • Slash dates, with an optional time: 05/03/2026, 5/3/26, 05/03/2026 14:30, 05/03/2026, 2:30 PM. Two-digit years 00 to 69 are read as 2000 to 2069, and 70 to 99 as 1970 to 1999.

  • Dates with month names, which mean the same in every region. A weekday, an ordinal (st, nd, rd, th) and a time are optional. Day first: 5 March 2026, 5-Mar-2026, Tuesday, 5 Mar 26, 9th Nov, 2026. Month first: March 5, 2026, Mar 5th 2026, November 9th 2026, 07:30 am. Time first: 2:32 PM, 12th Nov, 2026, 14:30 2026-11-12.

  • Times on their own are read as today in the printing time zone: 18:00, 7:30 pm, 7.30am, 12 am, 24:00.

  • Words: now, today, midnight, noon, tomorrow, yesterday. These work well as the second value in date_format: {$date|date_format:"%d/%m/%Y":"now"}.

  • Number timestamps: date_format reads a number as Unix time, in seconds, or in milliseconds if it is 10^12 or more. strtotime does not. It reads 4 digits as a 24-hour time (0730 is 07:30) and 8 digits as YYYYMMDD (20260305 is 5 March 2026).

  • Empty dates: blank text, null, 0000-00-00 and 0000-00-00 00:00:00 print nothing, or use the default date if you gave one.

Which order a slash date is read in

A slash date such as 05/03/2026 is read in the order used by the region of the printing locale:

  • Day first: Australia, New Zealand, Ireland and the UK. 05/03/2026 is 5 March 2026.

  • Month first: the United States and Canada. 05/03/2026 is 3 May 2026.

  • A date that can only be read one way, such as 25/03/2026, is always read that way.

To avoid mix-ups, send dates as ISO dates (2026-03-05) or with a month name (5 Mar 2026) wherever you can.

Format codes

date_format works out which style you used. If the format contains a %, it uses the percent codes, and month and day names follow the language of the locale. If it has no %, it uses the letter codes, and names are always in English. To print a letter as text with letter codes, put a backslash before it inside single quotes ('d/m/Y \a\t g:i a') or two backslashes inside double quotes.

Common percent codes

Code

What it gives

Example

%Y %y

4-digit year, 2-digit year

2026, 26

%m %b or %h %B

Month number, short name, full name

03, Mar, March

%d %e

Day, with a leading zero or a leading space

05, 5

%a %A

Short weekday, full weekday

Thu, Thursday

%H %k

24-hour, with a leading zero or a leading space

09, 9

%I %l

12-hour, with a leading zero or a leading space

02, 2

%M %S

Minutes, seconds

30, 00

%p %P

AM or PM, am or pm

PM, pm

%R %T %r

HH:MM, HH:MM:SS, hh:mm:ss AM/PM

14:30, 14:30:00, 02:30:00 PM

%F %D or %x

YYYY-MM-DD, MM/DD/YY

2026-03-05, 03/05/26

%z %Z

Offset from UTC, time zone abbreviation

+1100, AEDT

%u %w %j

Weekday 1 to 7 (Monday is 1), weekday 0 to 6 (Sunday is 0), day of the year

4, 4, 064

%V %G %g

ISO week, ISO week-year (4-digit and 2-digit)

10, 2026, 26

%U %W %C %c %X %s %n %t %%

Week number (Sunday or Monday start), century, full date and time, time, Unix seconds, new line, tab, a % sign

Common letter codes

Code

What it gives

Example

Y y

4-digit year, 2-digit year

2026, 26

m n M F

Month number with and without a leading zero, short name, full name

03, 3, Mar, March

d j S

Day with and without a leading zero, ordinal ending

05, 5, th

D l N w

Short weekday, full weekday, weekday 1 to 7, weekday 0 to 6

Thu, Thursday, 4, 4

H G h g

24-hour with and without a leading zero, 12-hour with and without a leading zero

14, 14, 02, 2

i s v u

Minutes, seconds, milliseconds, microseconds

30, 00

a A

am or pm, AM or PM

pm, PM

e O P p T Z I

Time zone name, +1100, +11:00, Z or +11:00, abbreviation, offset in seconds, daylight saving (1 or 0)

Australia/Sydney, +11:00

W o t L z c r U B

ISO week, ISO week-year, days in the month, leap year, day of the year (0 to 365), ISO 8601, RFC 2822, Unix seconds, Swatch time

Work out hours between two times

Change the start and finish times with |strtotime, subtract, and divide by 3600:

{$s = $start_time|strtotime} {$e = $finish_time|strtotime} {$hours = ($e - $s) / 3600} {if $hours < 0}{$hours = $hours + 24}{/if} Total hours: {$hours|round:2}

The {if $hours < 0} line handles night shifts that finish after midnight, such as 22:00 to 06:00. For more on hours and totals, see How do I use maths and time calculations in a custom print on the dashboard?.

Which fonts print correctly?

The PDF is made on our servers, which only have certain fonts. A font that isn't on the list, and isn't embedded in your Word file, is replaced, which can change where lines and pages break. Arial, Times New Roman, Courier New, Verdana, Georgia, Trebuchet MS, Comic Sans MS, Impact, Andale Mono and Tahoma print as the same font. Calibri, Cambria and Century Gothic are replaced with similar fonts. Aptos, Candara, Consolas, Constantia, Corbel and custom fonts are replaced unless you embed them in a .docx.

Tahoma Bold is created from regular Tahoma, so it runs slightly narrower than on your computer.

For the full font list and the steps to embed fonts in Word, see [link to the print engine article].

Excel page setup

  • If a worksheet sets Fit to width or Fit to height, those settings are kept.

  • If a worksheet sets a paper size without those settings, the columns are fitted to 1 page wide and the rows run across as many pages as needed. This stops a long report shrinking onto one page you can't read.

What isn't supported?

These don't work. They print as written, count as false, or are refused:

  • Comments written as {* ... *}. They are not removed and print as written. Delete them from your template.

  • Other tags: {include}, {section}, {capture}, {php}, {counter}, {cycle}, {config_load}, {fetch} and {eval}.

  • Barcodes and QR codes.

  • Fillable PDF templates. Rebuild them as .docx.

  • Other functions. Only empty, isset, count and sizeof, is_array, is_numeric, strlen and trim work.

  • The shortcut $a ? $b : $c, and comparisons chained like $a < $b < $c. Use {if}...{else}...{/if} and && instead.

  • int(), rand() and srand() inside {math}. Use floor() or round() instead of int().

  • Maths inside brackets, such as $arr[$i + 1]. Work the number out first: {$idx = $i + 1}{$arr[$idx]}.

What are the best habits for reliable templates?

  • Turn off smart quotes in Word before you edit. The engine reads most curly quotes, but a curly apostrophe inside single quotes (‘Don’t’) can end the text early, and mixing straight and curly quotes ("Yes”) breaks the placeholder. In Word for Windows, go to File > Options > Proofing > AutoCorrect Options > AutoFormat As You Type and untick "Straight quotes" with "smart quotes". On a Mac, go to Word > Preferences > AutoCorrect > AutoFormat As You Type and untick the same option. To fix an existing document, use Find and Replace to replace " with " and then ' with '.

  • Keep each placeholder in one style. In Word, a placeholder takes the font, size, bold and colour of its first character ({), and any trailing text in its last run takes that style too. Never put tabs, line breaks, bookmarks, comments or images inside a placeholder. In PowerPoint, select a whole {if} or one-line {foreach} and apply one font and style, so it's kept as one run.

  • Put spaces around the minus sign. {$qty - 2}, not {$qty-2}.

  • Put brackets around a calculation before a modifier. {($qty * $rate)|number_format:2}.

  • Don't put quotes around numbers you compare. {if $hours > 8}, not {if $hours > "8"}.

  • Always close {tablerow} and {tableif}. Word and Excel close an open tablerow for you, and Word closes an open tableif, but writing the closing placeholder avoids surprises and works the same in every file type, including PowerPoint.

  • Use insert_image:300:0 for photos. Setting both width and height stretches pictures that have a different shape.

  • Put picture loops around paragraphs or table rows, not on one line. A loop on one line of Word can't repeat pictures or text boxes.

  • Send dates in an unambiguous format such as 2026-11-09 or 9 Nov 2026 when you control the data.

  • Use maths inside a placeholder before {math}. {math} prints nothing if any value is blank or has units such as "5 hours".

  • Know how |default differs from {if}. |default:"N/A" only acts on missing, null or empty answers, so it keeps 0, "0" and false. To replace 0 as well, use {if $val}{$val}{else}N/A{/if}.

  • Keep Word layouts simple. Prefer ordinary tables to floating tables with text wrapped around them. Avoid fixed-height text boxes in headers and footers, which can cut off longer answers. Use fonts from the supported list, or embed full fonts in the .docx.

Why doesn't my template print the way I expect?

What you see

Likely cause

How to fix it

A placeholder prints as written, such as {$...}

A missing $, a typo or wrong case in a modifier name (|Upper), unbalanced quotes, a number that can't be read (1e+5, 08), an {if} or {foreach} with no end, a {* ... *} comment, or an unsupported tag

Check the $, check the modifier spelling and case, straighten quotes, close every {if} and {foreach}, and delete {* ... *} comments

A placeholder prints nothing

The name doesn't match the data (names are case-sensitive), a list or group is printed directly, image data is printed without |insert_image, a division by zero, or {math} was given a blank or non-number value

Check the spelling and nesting, loop over lists, add |insert_image:W:H, check a divisor isn't 0 with {if $d != 0}, or use maths inside a placeholder instead of {math}

{if} always shows the {else} text

A condition that can't be read (unquoted text such as {if $s == Open}, a single = instead of ==, a missing $, an unsupported function) or a different case ("yes" and "Yes")

Put text in quotes ("Open"), use ==, add the $, or use |lower to ignore case

A table row doesn't repeat in Word

{foreach} and {/foreach} are both in the same cell, which repeats paragraphs in that cell, not rows

Put {foreach} in the first cell and {/foreach} in the last cell, or use {tablerow} for a one-cell table

A whole table row disappears when one answer is missing

Every cell in the row was left empty after a false {if}, or a false {tableif} removed the row

Put fixed text outside the {if} if the row should stay, or use {if} inside one cell instead of {tableif}

A picture is stretched or squashed

Both width and height are set in insert_image:W:H

Set one to 0, for example {$photo|insert_image:300:0}

A signature or photo is blank

Missing |insert_image, the address isn't a public https:// address, the image is over 10 MB or took over 5 seconds, or it sits in a one-line loop

Add |insert_image:W:H, check the address works over HTTPS, and put repeated pictures in whole paragraphs or table rows

Text after a placeholder turns bold or changes style

The placeholder in Word is split across differently formatted text and starts in bold

Select the whole placeholder and the spaces around it, and apply one style

The day and month are swapped on a date

A slash date such as 05/03/2026 was read in a different regional order

Send ISO dates (2026-03-05) or month names (5 Mar 2026)

An Excel loop prints as written

The loop spans sheets, sits inside another row loop, or shares a row with another loop

Keep both placeholders on one sheet, put nested loops inside one cell, and give each row loop its own row

A PowerPoint {if} or loop prints as written

The placeholders span shapes or slides, or are split across differently formatted text

Keep {if} in one run of the same formatting, and keep paragraph and table loops in the same text box or table

Fonts or page breaks differ in the PDF

The template uses a font that isn't on our servers, such as Aptos or a custom font

Use a supported font, or embed full fonts in the .docx

If you've tried these and a print still isn't right, contact us through chat or support and include the form or Site Diary name, the PDF you printed and a copy of how it should look.

Related articles

Did this answer your question?