Skip to main content
The code editor gives you full control of a template. Templates are HTML and CSS with Liquid, the same template language Shopify uses: {{ order_name }} prints the order’s name, {% for line_item in line_items %} repeats for every item. Foliant’s order variables follow Shopify Order Printer’s, so templates written for it mostly work as they are. The code editor is on every plan.

Open the code editor

Open the template in the editor and click the Code tab. Code templates open there directly. For a visual template, you first see the compiled code; click Edit code to change it. See Switch between Visual and Code. Above a code template, Not into code? We can help offers help from our team: select Contact support and tell us what the document should show, and we’ll help you set it up. Close the banner to hide it for good. The left pane has three tabs: The right pane is the live preview. It updates shortly after you stop typing.

Insert a field

  1. Put the cursor where the field should go.
  2. Click Insert field.
  3. Search for the field (for example “tracking” or “SKU”) under Search fields, and click it.
Foliant inserts its Liquid at the cursor, for example {{ shipping_address.city }}. Line item fields, such as {{ line_item.sku }}, only work inside the line items loop: insert Line items for the loop itself.

Search the code

Click the search button next to Insert field (or press ⌘F / Ctrl+F in the code) to find text in the template.

Code errors

The editor checks your code as you type and marks problems in the margin:
  • Errors stop you saving and pause the preview. An unclosed {{ or {% is an error. They’re listed in a Code errors banner above the editor, each with Go to line.
  • Warnings point out things that may be wrong but don’t stop you saving, for example an unknown Liquid filter, tag or object, an unknown HTML tag or CSS property, or an unclosed HTML tag.
When you save, Foliant also checks the template: the Liquid must be readable, HTML tags must be balanced, and inline SVG may only contain drawing elements. If something’s wrong, the save fails and a Failed to update banner lists up to five problems, with their line numbers where known. If the template saves but the preview can’t be rendered, a banner shows Liquid’s message and the line, when it’s known.

Write good templates

  • Money values are in cents: always print them with a money filter, such as {{ total_price | money }}. See Money and currency in templates.
  • Use | escape on text that customers typed, such as notes and addresses: {{ note | escape }}.
  • Use {{ 'subtotal' | t }} for wording that follows the document’s language. See Dates, languages and translations.
  • Use Foliant’s built-in snippets for VAT: {% include 'vat_breakdown' %} prints the VAT breakdown table, and {% include 'legal_notes' %} the legal notes (reverse charge, export, IOSS…).

Good to know

  • If a numbered template (invoice, credit note or quote) doesn’t print document_number anywhere, Foliant adds a small line with the number at the end of the document. See Document numbers in templates.
  • Page numbers and repeated table headers for code templates are on the template’s settings page, under Page layout.
  • To bring a template over from Shopify Order Printer or Order Printer Pro, use Import a template on the Templates page. See Import a template from Order Printer.