Liquid print templates
A Liquid print template is HTML that Formbox fills from a Questionnaire or a QuestionnaireResponse and returns as HTML or PDF. Templates are stored as FHIR Library resources. A questionnaire links one template per purpose (print, summary, narrative, or patient); the same Library can be print on one form and summary on another.
Language reference: Liquid template language. Render API: $render.
Author a template
Open the editor from Form Settings → Data → Rendering templates: click New template, or the pencil next to an existing one.
The workspace has three optional panels:
- Editor — HTML with Liquid tags.
- Form — the questionnaire, with no submit button. Fill it so the template has real answers.
- Preview — the live
$renderresult, including unsaved edits.
Toggle panels from the pane header. At least the editor or the preview stays visible. With preview on, Download PDF is on the right.
An AI chat sits on the right. It can read and rewrite the template, inspect the form, and check the last preview.
A new template starts as:
<div>{{ %resource.id }}</div>
%resource is the resource being rendered. Expressions inside the tags are FHIRPath. See the language reference for if, for, assign, capture, and escaping.
Save writes only the Library. Linking it to a questionnaire is the next step.
For PDF output, use tables rather than flexbox or grid. Inline or absolute images and CSS — relative URLs do not resolve. No JavaScript, webfonts, or external images.
Link to a questionnaire
The gear icon opens settings: template title, purpose, and Link to questionnaire. Search forms, tick or untick them, then Apply. Apply is disabled while the template has unsaved changes — save first.
From Form Settings you can also Use existing template (searches Libraries tagged as liquid templates) or New template. Unlinking removes the pointer on the questionnaire; a shared Library stays on the server.
A template linked as narrative is rendered on every QuestionnaireResponse submit and stored as QuestionnaireResponse.text. If rendering fails, the response is stored without a narrative. The output must be valid XHTML.
Render via API
Pass purpose to pick the Library linked on the form, or liquid-template-id to point at a Library directly. format: pdf returns a PDF; omit it for HTML. Full parameters: $render.
POST /QuestionnaireResponse/qr-1/$render
Content-Type: text/yaml
resourceType: Parameters
parameter:
- name: purpose
valueString: print
- name: format
valueString: pdf