Report Editor
The Report editor is where a report is written and tested. You edit the template, the script, the helpers and the partials in one window, and see the document that comes out of them without leaving it.
This page describes what the editor shows and what you can do with it. For the language of the report itself (the
onInit script, the Handlebars template, the helpers), see Coding Reports. For step-by-step use of the editor, from the user’s point of view, see Customise a report.
Open the editor
Section titled “Open the editor”There are three ways to open it, described in the user guide:
- Modify a report while printing, from the Modify button of the first step of printing;
- Modify a report from the file system, with Modify on the
.htfile; - Create a report, with New report in the file system.
The window
Section titled “The window”The window has four areas:
- the toolbar, at the top;
- the preview, on the left: the document generated by the report;
- the tabs, on the right: Template, Script, Helpers and Partials;
- the Debugger, at the bottom: the errors of the last run and the debug entity in use.

The title of the window is the name of the report; until it has one, the name of the file, or Unnamed report for a report that was never saved.
Toolbar
Section titled “Toolbar”| Control | What it does |
|---|---|
| Save (floppy disk, with a menu) | Save overwrites the file, Save as saves it with another name or in another folder. See Saving |
| Configuration (gear) | opens the configuration dialog |
| Select debug entity | chooses the item to test the report with. See Testing |
| Run | generates the document with the debug entity and shows it in the preview |
| Auto preview | runs the report again by itself after every change |
Configuration
Section titled “Configuration”The Configuration dialog holds the metadata of the report: the information that does not belong to its code. These are the rules of the editor:
| Field | Rule |
|---|---|
| Name | Required. A report cannot be saved without it |
| Tag | Optional. A tag is 2 to 20 characters long: lowercase letters, numbers, underscores and hyphens, no spaces |
| Launch points | A report with no launch points never appears in a picker. See Launch points |
| Country, Language | See Country and language |
| Output type | HTML, CSV or Plain text. It also sets how the Template tab is highlighted: as HTML for HTML, as plain text for the others |
Description is optional.
Confirm applies the changes to the report being edited: they are saved to the file when you save it. Cancel discards them.
Example. The configuration of the report “Material resource badge (QR)”, with every field filled in:
| Field | Value |
|---|---|
| Name | Material resource badge (QR) |
| Description | Printable CR80 badge with QR code, name and code — equipment, substances, work environments |
| Tag | badge, qr |
| Launch points | equipment, substance, work_environment |
| Country | United Kingdom |
| Language | English (United Kingdom) |
| Output type | HTML |
With this configuration the report appears in the report picker of a piece of equipment, a substance and a work environment, for people working in the United Kingdom and in English.
The tabs
Section titled “The tabs”| Tab | What it contains |
|---|---|
| Template | the template |
| Script | the script, with the onInit function |
| Helpers | the report-specific helpers |
| Partials | the partials included in the template, one per row |
The Script and Helpers tabs mark syntax errors in the margin of the editor, as you type.
Example. A minimal report shows the name of an item in capitals, with a helper:
| Tab | Content |
|---|---|
| Template | <h1>{{upper name}}</h1> |
| Script | async function onInit() { return { name: 'Pump 1' }; } |
| Helpers | var helpers = { upper: function (text) { return String(text).toUpperCase(); } }; |
| Partials | none |
The result is a title that reads PUMP 1.
Partials
Section titled “Partials”Each row of the Partials tab has an Alias, the file and a Select button:
- Add a row.
- Click Select and choose the file. The picker shows the
.ht,.htmland.hdocfiles, starting from the project the report belongs to. - The Alias is filled in with the name of the file without its extension, if you have not typed one. Change it to the name you want to use in the template.
- In the Template, write
{{> alias}}where the piece has to appear.
A row with no alias or no file is ignored when the report is saved. What a partial is and how it uses the data of the report is explained in Partials.
Testing
Section titled “Testing”To test a report you first choose the debug entity (see Report Concepts):
- Click Select debug entity.
- If the report has more than one launch point, choose the one you want to test: the report sees it as
this.runtime.target. - Choose the item. The list shows only items of the type that launch point works on: a piece of equipment for
equipment, an office foroffice.equipment_list. A launch point that has no item behind it (for exampleperson_list) needs no choice.
Until you choose a debug entity the preview shows a message asking for one, and Run does nothing. Once chosen, the Debugger header shows the entity and the launch point in use, and a Clear button that drops them.
Click Run to generate the document. The editor first checks the syntax of the template (as Handlebars reads it), of the script and of the helpers: if there is an error the report does not run, the preview keeps the last result and the error is listed in the Debugger. Otherwise the report runs as described in How a report runs, with the debug entity as its this.runtime, and the result appears in the preview, in a document of its own, so that a full page with <html>, <head> and <body> looks as it will when printed.
Example. With the debug entity of a pump, a report with launch points equipment and substance is tested like this:
- Click Select debug entity.
- Choose the launch point
equipment. - Choose the pump from the list of equipment.
- Click Run: the document appears in the preview.
Debugger
Section titled “Debugger”Each error is a row with four columns:
| Column | Content |
|---|---|
| Time | when the error happened |
| Place | where: script, helpers or template |
| Name | the type of error, for example SyntaxError or ReferenceError |
| Message | the message of the error |
Example. If in the script you write return { name: foo }; by mistake, without defining foo, the Debugger lists a row:
| Time | Place | Name | Message |
|---|---|---|---|
| 10:42:03 | script | ReferenceError | foo is not defined |
The report does not generate the document until the error is fixed.
Auto preview
Section titled “Auto preview”With Auto preview on, the report runs by itself a moment after the last change to the template, the script, the helpers, the partials, the configuration or the debug entity. The Debugger is cleared before each run, so it lists only the errors of the report as it is now. It does nothing until a debug entity is chosen.
Saving
Section titled “Saving”Click Save to open the menu:
- Save as opens the file picker. It shows only the folders you can write to, and saves a
.htfile. After the first save, the editor keeps working on the new file. - Save overwrites the file the editor is working on: the file the report was opened from, or the one chosen with Save as. It is not available for a new report that was never saved.
A report that comes from outside the project (the 4HSE catalogue or a partner’s) and was opened from the print wizard cannot be overwritten: Save is disabled until you use Save as in a folder of the project. The original stays as it was, and the printing uses your copy when you choose This project in the report picker (see Choose a report).
A report cannot be saved without a name: the editor asks for it and does not save.
When a report is saved, the keys the editor does not know are kept as they are.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.