Template Language Reference
Reference used in the user-configurable templates in WarmHub
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]
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 dataquery
: 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 fullhttp://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
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 stringsquery
: 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 sensitiveThe 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
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 filteringoperator
is one of the following:eq
: equalsgt
: greater thangte
: greater than or equal tolt
: less thanlte
less than or equal to
value
is the desired value you would like to filter toThe 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 bolditalic
: Makes the text italicizednumber(precision: integer = 5)
: Formats a number to a certain precision, using scientific notation if possiblenumber() 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 TypeScriptNumber.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-13formatBytes() 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
Last updated