Skip to main content

Watson

Watson is the name of a template builder based on a Word document. The principe is simple, the user can create a template of a document that contains variables. To generate a document, the template is sent to an application called "Watson", with a full dataset. Watson will parse the template, and replace the variables inside by the value, then it will return the word document.

The delimiter defined in Watson are {{ and }}, and they MUST be exactly those ones. Pay attention that if a delimiter does not respect this, Watson will trigger an error when generating. Note that templates can uses curly quotes, Watson will convert them to smart quote and that is not an error. Also the user can use double quote in place of single quotes, this is not an error in watson.

Tailormade functions

To be a maximum safe on the generation, Watson provides multiples function that MUST be used in the template in order to access to some properties or check some data. The best practice is to use them, that ensure Watson to keep the hand on what could be shown or not.

Errors

Using a word document as a template to generate a pdf following a certain style might be a good idea. But the truth behind this is that a docx document is in fact a big .xml document, that means that selecting some text to wrap them between brackets or creating conditions or function calls inside table might be a real nightmare to debug. You can find some common errors on the section Common errors

Docx templates

Watson uses behind a library developped that is called docx-template.

You can find more explanation about it on the DOCX-TEMPLATES section