HTML Templates
Last updated
Last updated
HTML Templates are used for emails and exports to specify the layout of the email or PDF and HTML files. They refer to form fields in HTML elements such as paragraph (<p>) or ordered list (<o>).
Apart from HTML syntax, FlexiForms uses HandleBars syntax to replace the form field values in the HTML elements.
An example template is as follows:
This email template code tells us that:
The text "Hi There" will be in the first paragraph (<p> is the paragraph element in HTML)
the value of the verification_fullname field on the form should preceed "has given the following testimony for {{employee}}". So, if the verifiction_fullname is "Robert Ludlum" and the employee value is "Carla Grand", then the text "Robert Ludlum has given the following testimony for Carla Grand".
The text "Testimony" will be displayed a third level header.
The answer to the Testimony question will follow the header in a pragraph.
The email will end with [Testimony cycle:2025-4] if the value of the testimony_cycle field is "2025-4".
When the button titled "preview" is clicked, the following HTML content is displayed based on the discussed template code.
If a complex field (the question that can store multiple values) is used in the form, such as a dynamic panel, we need to access each value using HandleBars helper "#each", as in the following example:
In this examples, we are iterating over the files uploaded via an multi-file upload question and displaying them. Here is the HTML content preview:
When the helpers button is clicked, you can see many examples to HandleBars helpers. You can play around with the code and see the result immediately. The code provided would probably include example uses of more helpers than you would need.
Auto-template button generates either table-based or title:value based templates for you. It is typically used to include all the form fields to the template in a structured layout. Then you can modify the template code according to your needs.
As can be seen from below, a list of available fields are present for you to refer to in the Template page.
Note please that the form field list does not only contain the question in the form design but also other fields such as "form_id", form_data_id and testimony_cycle. In the next section we will see what kind of fields are available for FlexiForms when a field name is required for Templates, Verification and Jobs.