...
Pass a template HTML string containing a Handlebars template as described in Installation.
Pass the ID of a
template
element containing a Handlebars template as described in Installation.Define the new Handlebars template s as the child content of a control
...
Code Block | ||
---|---|---|
| ||
Hawksearch.handlebars.registerHelper('add', function (value1: number, value2: number): number { return value1 + value2; }); |
and
This function returns whether or not all passed arguments resolve to true
:
Code Block | ||
---|---|---|
| ||
Hawksearch.handlebars.registerHelper('and', function (...values: Array<any>): boolean {
return values.slice(0, -1).every((v) => !!v); // Omit last argument as that is the Handlebars options function
}); |
attribute
This function renders an attribute or attribute value if the given condition resolves to true
:
Code Block | ||
---|---|---|
| ||
Hawksearch.handlebars.registerHelper('attribute', function (attribute: string, condition: any): string { return condition ? attribute : ''; }); |
concat
This function combines multiple values into a single string:
Code Block | ||
---|---|---|
| ||
Hawksearch.handlebars.registerHelper('concat', function (...values: Array<any>): string { if (values.length < 2) { return ''; } return values.slice(0, -1).join(''); // Omit last argument as that is the Handlebars options function }); |
currency
This function formats a value as currency:
Code Block | ||
---|---|---|
| ||
Hawksearch.handlebars.registerHelper('currency', (value: number | Array<number> | undefined, decimals: number, defaultValue?: number): string | undefined => {
if (typeof defaultValue === 'object') {
defaultValue = undefined;
}
if (value instanceof Array) {
value = value[0];
}
return formatCurrency(value ?? defaultValue ?? 0, decimals);
}); |
eq
This function returns whether two values are equivalent:
...
Code Block | ||
---|---|---|
| ||
Hawksearch.handlebars.registerHelper('gte', function (value1: any, value2: any): boolean { return value1 >= value2; }); |
number
This function formats a number:
Code Block | ||
---|---|---|
| ||
Hawksearch.handlebars.registerHelper('number', (value: number | Array<number> | undefined, decimals: number, defaultValue?: number): string | undefined => {
if (typeof defaultValue === 'object') {
defaultValue = undefined;
}
if (value instanceof Array) {
value = value[0];
}
return formatNumber(value ?? defaultValue ?? 0, decimals);
}); |
or
This function returns whether either provided value resolves to true
:
Code Block | ||
---|---|---|
| ||
Hawksearch.handlebars.registerHelper('or', function (...values: Array<any>): boolean { return values.slice(0, -1).some((v) => !!v); // Omit last argument as that is the Handlebars options which would always resolve to true }); function }); |
string
This function displays a specified string with an optional default value:
Code Block | ||
---|---|---|
| ||
Hawksearch.handlebars.registerHelper('string', (value: string | Array<string> | undefined, defaultValue?: string): string | undefined => {
if (typeof defaultValue === 'object') {
defaultValue = undefined;
}
if (value instanceof Array) {
value = value[0];
}
return value ?? defaultValue;
}); |
Info |
---|
This is most likely to be used in the context of the Search Results Item Component. |
subtract
This function returns the difference of two values:
...
Info |
---|
For more information, see Global Models. |
lt
lte
gte
or
subtract
...
Control content
Note exclude helper
...
Config string
...