Getting Started with Document Templates
Document Templates let you design the documents Mercura generates for a quote, such as a PDF offer, an Excel price list or an order confirmation, in the tools you already know. You build the layout in Microsoft Word, Excel or as an HTML page, and add small template tags where the quote data should appear. When a quote is generated, Mercura replaces every tag with the real values from that configuration: the customer, the selected products, prices, discounts, request fields and more.
You don’t need to be a developer. Designing a good template is mostly about knowing your editor (styles, tables, headers and footers), plus a handful of tags that are explained in this section.
How it works
Every generated document is made from two ingredients:
- Your template: a
.docx,.xlsxor.htmlfile containing your layout, logos, static text and template tags. - The quote data: a structured data set that Mercura builds from the submitted configuration. It contains everything about the quote, from the customer’s name to every selected option and the Bill of Materials (BoM).
Mercura merges the two and produces the final document. Your template file itself is never changed, so the same template can be used for every quote.
Quote {d.id}-{d.revision_number}Prepared for {d.name}Total: {d.conf_total:formatN(2)} {d.currencyCode}Quote 2586-1Prepared for Jane DoeTotal: 516,551.00 DKKSupported template formats
| Format | Best for | Notes |
|---|---|---|
Word (.docx) | Paginated quotes and offers with headers, footers, page numbers and long text | The most common choice for PDF quotes. See Word templates. |
Excel (.xlsx) | Price lists, BoM exports and anything that needs working formulas | See Excel templates. |
HTML (.html) | Pixel-perfect PDFs styled with CSS | See HTML templates. |
Create your first template
-
Prepare your editor. Turn off automatic “smart quotes” in Word (see Editor setup below). Tags only work with straight single quotes
'. -
Design the layout. Create your document as usual: logo, company details, headings, tables, terms and conditions.
-
Add template tags. Type tags where the quote data should appear, for example
{d.name}for the customer name or{d.conf_total}for the total price. Use the Data Reference to find the right tag. -
Upload the template. Go to Settings → Document Templates and upload your file.
-
Test it. Generate a quote and check the output. Adjust the template and upload it again until you are happy with the result.
Anatomy of a template tag
All template tags are written between single curly braces. The first letter tells Mercura where the value comes from:
| Tag | Meaning | Example |
|---|---|---|
{d.…} | A value from the quote data | {d.name} |
{c.…} | A value you computed earlier in the template, or the built-in current date {c.now} | {c.now:formatD('DD-MM-YYYY')} |
{#… = …} | Declares a shortcut (alias) to a long path | {#bom = d.form_submissions[0].form.bom} |
{$…} | Uses a shortcut | {$bom.summary.rows[0].value} |
{o.…} | A document option, such as language or time zone | {o.lang=da-DK} |
A tag can be followed by one or more formatters, separated by a colon, that transform the value before it is printed:
{d.created_at:formatD('DD MMMM YYYY')}{d.name:upperCase}{d.conf_total:add(d.vat_total):formatN(2)}Formatters run from left to right, and each one receives the result of the previous one.
Editor setup
Word and most text editors automatically replace straight quotes ' with typographic “smart quotes” ’. Template tags only accept straight single quotes, so switch this off before you start:
- Microsoft Word (Windows): File → Options → Proofing → AutoCorrect Options → AutoFormat As You Type → uncheck “Straight quotes” with “smart quotes”. Do the same on the AutoFormat tab.
- Microsoft Word (Mac): Tools → AutoCorrect → AutoFormat As You Type → uncheck “Straight quotes” with “smart quotes”.
- LibreOffice: Tools → AutoCorrect Options → Localized Options → uncheck Replace for both single and double quotes.
Styling tags
The generated value takes the font, size and colour of the first character of the tag (the opening {). Make the { bold and the output is bold.
Long tags can make a template hard to read. A common trick is to keep the first { at the normal size and set the rest of the tag to a tiny font size (for example 1 pt). The output still uses the style of the first character.
Language and time zone
By default, numbers and dates are formatted in English. You can set the language and time zone for a template by adding option tags anywhere in the document. They are removed from the output.
{o.lang=da-DK}{o.timezone=Europe/Copenhagen}With {o.lang=da-DK}, {d.conf_total:formatN(2)} prints 516.551,00 instead of 516,551.00, and month names in dates are printed in Danish.
Next steps
- Learn what data is available in the Data Reference.
- Insert single values with Inserting Data.
- Build product tables with Repeating Content.
- Copy a complete, working Example Quote Template.