WarmHub Docs
  • Welcome to WarmHub
  • Getting Started
  • The Language of Digital Trust
    • Articles, Claims, Evidence, and Sources
    • Reproductions and Replications
  • Trust Repositories
    • Creating a Repository
    • ReadMe
    • Data
      • Templates for Typed Instance Data
    • Types
      • Importing Types From Other Repos
      • Creating Types
      • Claims Computed on WarmHub
    • Events
    • Webhooks
    • About
    • Committing To Your Repo
    • Customizing Templates
      • Template Language Reference
  • Guides
    • Units of Measurement Repo
    • Templates for Units of Measurement
Powered by GitBook
On this page
  • Base language
  • Components
  • Property
  • Related List
  • List
  • Instance Summary
  • Instance Summary List
  • Repo Summary
  • Embed
  • Special fields
  • Filtering
  • Formatters
  1. Trust Repositories
  2. Customizing Templates

Template Language Reference

Reference used in the user-configurable templates in WarmHub

PreviousCustomizing TemplatesNextUnits of Measurement Repo

Last updated 10 days ago

Base language

The template language available in the editor is based on Markdown. It is further extended using Nuxt Markdown Components (MDC). Documentation for Nuxt MDC can be found at this link:

Components

There are a variety of components available to the template author which enhance the presentation of data past what is available in vanilla Markdown. References to these components are done through the Nuxt MDC syntax.

Certain shorthand names to components are also available. Shorthand names are a quick way to create components with some defaults automatically applied.

Some components also have alternate keys. They function as aliases, and you can use them in both the full form and shorthand form, if applicable.

Property

Displays a single property from a object.

::property
---
data: object reference
label: string (optional)
format: formatter (optional)
---
::

Property

Description

Required

data

A dot-notated reference to a particular field available in the instance data

Yes

label

Any string

No

format

A formatter object [formatter](any arguments)

No

Shorthand: :property [instance.data]

Data used in the following examples:
"instance": {
    "$id": "meter",
    "definingOrg": "BIPM",
    "description": "The meter is the length of the path travelled by light in vacuum during a time interval of 1/299792458 of a second.",
    "baseProperty": "length"
}

Full example

::property
---
data: instance.name
label: Name
format: italic
---
::

Shorthand example

:property name

Related List

::related-list
---
data: object reference (optional)
label: string (optional)
headers: string[] (optional)
selectedColumns: string[] (optional)
format: formatter (optional)
query: string (optional)
---
::

The data of the related list is entered in two ways. Using one and only one way is required:

  • data: A dot-notated reference to a record of strings and objects in the instance data

  • query: A string which can take on the following forms:

    • Instance with explore link: /api/<org>/<repo>/<typeName>/<id>/explore + (optional) /r/<revision>

    • Instance by type: /api/<org>/<repo>/<typeName>

    • Instance type with search query: /api/<org>/<repo>/<typeName>?query=querystring

      • See appendix about search query for more information

In the query property in the related list component, there exists two macros which can be utilized anywhere in that property for ease of referencing the current type:

  • $id resolves to the identifier for the current instance

  • $wid resolves to the full http://repo.warmhub.com/... link for the instance

The related list can be further configured using the following optional properties:

Property

Description

Required

label

Any string

No

selectedColumns

A list of the keys of the columns to display (left to right)

No

headers

A list of strings to use as column headers (left to right)

No

format

A key:value list of formatters, in the following form: [columnName]:[formatter]|[columnName]:[formatter]…

No

List

A list of properties.

::list
---
data: object reference
label: string (optional)
---
::

Property

Description

Required

data

A dot-notated reference to an array of displayable items

Yes

label

Any string

No

Shorthand: :list [instance.data]

Instance Summary

::instance-summary
---
wref: string
label: string (optional)
---
::

A wref takes on the form of http://repo.warmhub.com/<org>/<repo>/<type>/<id> + (optional) /r/<revision>.

Property

Description

Required

data

A dot-notated reference to an array of displayable items

Yes

label

Any string

No

Acceptable keys: summary, instance-summary

Shorthand: :[key] wref

Data used in the following examples
"instance": {
    "$id": "meter",
    "definingOrg": "BIPM",
    "description": "The meter is the length of the path travelled by light in vacuum during a time interval of 1/299792458 of a second.",
    "baseProperty": "length"
}

Full example

::summary
---
label: Summary card
wref: http://repo.warmhub.com/ericliu0000/uom5/data/unit/meter
---
::

Summary example

:summary http://repo.warmhub.com/ericliu0000/uom5/data/unit/meter

Instance Summary List

::list-summary
---
data: object reference (optional)
label: string (optional)
query: string (optional)
---
::

Similar to the related list object, you can supply data for the instance summary list in the following manners:

  • data: A dot-notated reference to a list of wref strings

  • query: A string which can take on the following forms:

    • Instance by type: /api/<org>/<repo>/<typeName>

    • Instance type with search query: /api/<org>/<repo>/<typeName>?query=querystring

      • See appendix about search query for more information

    • Instance by root type: /api/<org>/<repo>/dataByType/<rootType>

      • dataByType is case sensitive

      • The available root types are: articles, sources, evidence, claims

Repo Summary

Shows the summary template of another repository.

::repo-summary
---
org: string
repo: string
label: string (optional)
---
::

Property

Description

Required

org

A string which is the name of an org

Yes

repo

A string which is the name of a repo

Yes

label

Any string. Defaults to {org} - {repo}

No

Acceptable keys: repo, repo-summary

Shorthand: :[key] org/repo

Example 1 (Full)

::repo-summary
---
org: ericliu0000
repo: uom5
---
::

Example 2 (Shorthand)

:repo ericliu0000/uom5

Embed

Embeds external content into your template via URL.

::embed-item
---
src: string
height: string (optional)
---
::

Property

Description

Required

src

The link to the item to embed

Yes

height

The desired height of the embed (e.g. 500px)

No

Acceptable keys: embed, frame, iframe, embed-item

Shorthand: :[key] src

Special fields

Filtering

Filtering is provided by query string (?filter=) on the API or web routes which return the data by instance type. It allows you to query by certain values in the data. The query string takes on the form of:

field: operator: value

  • field is a dot-notated reference to the field of the object on which you are filtering

  • operator is one of the following:

    • eq: equals

    • gt: greater than

    • gte: greater than or equal to

    • lt: less than

    • lte less than or equal to

  • value is the desired value you would like to filter to

    • The value will be interpreted as the same type (either text, number, or boolean) as the type of the particular field

Formatters

In related lists, numbers in relevant columns are automatically formatted to 5 digits of precision, and automatically converted to scientific notation where relevant.

  • bold: Makes the text bold

  • italic: Makes the text italicized

  • number(precision: integer = 5): Formats a number to a certain precision, using scientific notation if possible

    • number() on 12345 = 12345

    • number() on 123456 = 1.2346e+5

    • number(6) on 123456 = 123456

  • round(decimals: integer = 0): Rounds a number to a certain number of decimal places. Equivalent to TypeScript Number.toFixed(decimals)

    • round() on 12345 = 12345

    • round(2) on 12345 = 12345.00

    • round() on 0.016 = 0

    • round(2) on 0.016 = 0.02

  • formatBytes(decimals: integer = 2): Formats a number to a power-of-2 quantity of bytes specified in IEC 80000-13

    • formatBytes() on 1234 = 1.21 KiB

    • formatBytes(3) on 1234 = 1.205 KiB

    • formatBytes() on 1048575 = 1024 KiB (2^10 - 1 bytes)

    • formatBytes() on 1048577 = 1 MiB

nuxtjs/mdc · Nuxt Modules