atomic-recs-result-template

This is for:

Developer
In this article

The atomic-recs-result-template component determines the format of the query results, depending on the conditions that are defined for each template. A template element must be the child of an atomic-recs-result-template, and an atomic-recs-list must be the parent of each atomic-recs-result-template.

Note: Any <script> tags defined inside of a <template> element will not be executed when results are being rendered.

Properties

Property Attribute Description Type Default

conditions

A function that must return true on results for the result template to apply.

For example, a template with the following condition only applies to results whose title contains singapore: [(result) => /singapore/i.test(result.title)]

ResultTemplateCondition[]

[]

ifDefined

if-defined

The field that, when defined on a result item, would allow the template to be applied.

For example, a template with the following attribute only applies to result items whose filetype and sourcetype fields are defined: if-defined="filetype,sourcetype"

string | undefined

ifNotDefined

if-not-defined

The field that, when defined on a result item, would prevent the template from being applied.

For example, a template with the following attribute only applies to result items whose filetype and sourcetype fields are NOT defined: if-not-defined="filetype,sourcetype"

string | undefined

mustMatch

must-match

The field and values that define which result items the condition must be applied to. For example, a template with the following attribute only applies to result items whose filetype is lithiummessage or YouTubePlaylist: must-match-filetype="lithiummessage,YouTubePlaylist"

Record<string, string[]>

{}

mustNotMatch

must-not-match

The field and values that define which result items the condition must not be applied to. For example, a template with the following attribute only applies to result items whose filetype is not lithiummessage: `must-not-match-filetype="lithiummessage"

Record<string, string[]>

{}

Methods

getTemplate

Gets the appropriate result template based on the conditions applied.

Signature: getTemplate() => Promise<RecsResultTemplate<DocumentFragment> | null>

Returns: Promise<ResultTemplate<DocumentFragment> | null>