Skip to main content

Record and Set Templates

Templates are fast, flexible scripted visualizers that can be semantically bound to either individual records or to sets of records.

You can create these templates as follows:

  1. Without a Templates Folder
  • If you don’t have a templates folder in your workspace you can right click in the workspace that you want to create templates and click to Create —> Custom Template .
  1. With an Existing Templates Folder
  • If you already have a templates folder you can just right click on templates folder and then Create —> Custom Template .

A modal will appear, prompting you to enter the template name and optionally select a concept. The concept you choose will be semantically bound to the template.

Using the Templates Editor

To configure your template, right-click on the Templates folder and choose Open With → Templates Editor. In the Templates Editor, navigate to the Settings tab, where you can customize the following properties:

Settings:

    • Name : The name of the template.
  • Description : A brief description of the template’s purpose.
  • Semantic Bindings : Select multiple concepts that will be semantically bound to the template (e.g., actor, phone, positions).
    • Bindings:

For each Semantic Binding , you can configure the following properties:

        • Concept : This must either inherit or match the concept selected in Semantic Bindings .
    • Role :  Define the role of the concept, such as record_viewer.
    • Priority : Set a priority for the template. For example, a priority of 1 will make this template more prominent in views like Record Viewer compared to other templates.
    • Maximize : A boolean option that, if set to true, ensures that the template opens in full-screen mode within the Record Viewer.

Additional Settings:

    • Single/Multiple Record : Specify whether the template supports single or multiple records.
  • Layout :

  • Blurhash : Optionally, insert a screenshot to display while the template is loading.

  • Type : The language in which the template is written.

  • isApp/isTemplate : Specify whether this is an app or a template.

  • Params

  • Inside the template folder:

    • context_builder.js - this is a script that will produce the JSON (context in NUNJUCKS API terms https://mozilla.github.io/nunjucks/api.html ) which is then passed to the templates
      • An input indicating what is the subject (typically a record or a search)
      • The ontology api
    • index~~.~~njk - the main one, meant to be visualized in a full tab. This is an os_workspace_item with os_content_type='os_template' and a template_type property of os_content_type field set to 'nunjucks' then we know it is a https://mozilla.github.io/nunjucks/api.html#renderstring file. Future: We will support other rendering engines.
    • other files as required which can serve as resources for the templates (e.g. a logo, css) notice that these should be easily usable by the end user.
    • manifest - this is an os_workspace_item having os_content_type='os_template_manifest' in which os_item_content contains:
      • the template name to be visualized on the tab
      • the usage parameter: FULL_SCREEN, TOOLTIP, RESULT_ROW (tab mode) tooltip . This declares if this is to be used as full screen record or can be used in smaller context e.g. a tooltip, or as a row in a result table. Note that one can specify more than one usage parameters. usage parameters are passed both to the context_builder and the template which can then use conditional logic
      • (optional) template priority (1-100) in case of conflicts it will use lexicographical order
      • (optional) template icon to be visualized in the tab

Sandbox/Playground for template editing

A sandbox/playground functionality is provided for people who are editing templates, including a record search/selector, the editor cells, and a preview of what the result looks like.

Lifecycle of Record Templates

Templates go hand in hand with the Ontology definitions as they refer to Concepts and Attributes (fields) as defined in the ontology

One has to be careful so that the templates and ontology do not go out of sync.

Example of out of sync scenarios:

  • A Concept is renamed in the ontology

➝ the templates directory name needs to be renamed!

➝ context.js logic needs to be changed

  • A field is added in a Concept

➝ context.js might need to fetch the additional field and add it to the context

➝ template.njk might need to be updated to show the additional field

  • A Concept is created in the ontology

➝ Appropriate templates need to be created e.g. starting from an existing one..