Result Templates Manager
Manager in which result templates can be registered. Registered templates can then be selected for a given result based on a list of conditions and priority.
Constructor
Creates a new ResultTemplatesManager
instance.
Parameters
-
engine: HeadlessEngine
Returns ResultTemplatesManager<Content, State>
Methods
registerTemplates
Registers any number of result templates.
Parameters
How to deal with spread syntax?
selectTemplate
Returns the highest priority template for which the given result satisfies all conditions. In the case where satisfied templates have equal priority, the one that was registered first is returned.
Parameters
-
result: Result
Returns Content
Interfaces
ResultTemplate<Content>
content
(Content, required)
Stored content of the template.
conditions
(ResultTemplateCondition[], required)
List of conditions to fulfill for a template to be selected. See Result Templates Helpers for easy ways to generate conditions.
priority
(number)
0 based value which the manager will fallback to when multiple conditions are fullfilled. Higher numbers have priority and are evaluated first.
fields
(string[])
List of index fields that are necessary to render the template.