Find 25.2
Find Administration Guide

# Create Template Files

Find processes templates by using `handlebars.js` (for more information, see http://handlebarsjs.com/).

Each template file must produce HTML output that represents one document.

Find runs the templates with the following Handlebars context:

    interface ResultTemplateData {
       reference: string;
       title: string;
       date: string;
       database: string;
       promotionName: string|undefined;
       summary: string; // The highlighted summary, should not be HTML escaped
       url: string|undefined; // URL of the original document or media file
       icon: string; // Icon class based on content type
       similarDocumentsUrl: string|undefined; // URL for linking to the similar documents view, only in result and promotion
       thumbnailSrc: string|undefined, // Source attribute to load the thumbnail in an <img> tag
       age: string; // Internationalised age of the document (e.g. "3 years ago")
       fields: {id: string, values: string[], displayName: string, advanced: boolean}[];
       weight: number;
    }

The following table also describes some Find custom helpers that you can use in your templates.

Helper | Description
--- | ---
`equal` | A block helper that takes two or more arguments. The block is printed only if the first argument is referentially equal to any of the subsequent arguments.
`hasField` | A block helper that takes one string argument (the field). The block is printed only if the document has a value for the field.
`hasFieldValue` | A block helper that takes two string arguments, the field and the value. The block is printed only if the document contains the specified value in the specified field.
`getFieldValue` | Prints the first value for the specified field. You can also use `getFieldValue` as a block helper.
`getFieldValues` | Prints all values for the specified field. You can also use `getFieldValues` as a block helper. You can optionally add the following parameters: `max`. The maximum number of values to display. For example, `max=2`. By default, the helper prints all available values. `delimiter`. The delimiter to use between field values. For example, `delimiter='|'`. The default value is `', '` (a comma with a space). When you use `getFieldValues` as a block helper, the default value is a space. `ellipsis`. The string to use after the final value, when there are more than the specified maximum. For example, `ellipsis=', and more.'`. The default value is `...`. You can set ellipsis to `''` to turn off the ellipsis.
`withField` | A block helper that executes the block in the context of the given field.
`i18n` | Prints a string from the application internationalization file.
`percentage` | Formats the specified number as a percentage. You can optionally add the following parameters: `min`. Min. `max`. Max. `round`. The option to use for rounding the value. This parameter accepts the following values: `round`. Use standard rounding rules. `ceil`. Round up to the next integer. `floor`. Round down to the next integer. `N`. A number of decimal places to round to. `false`. Disable rounding.
`placeholderTemplate` | Fills in a template that contains placeholder values, by using variables that you specify. This helper takes two arguments. The first argument is a hash, array, or string that defines the values to use in the specified template. The second argument is the template string that contains placeholder values. You can also optionally add the following parameters: `placeholder`. The symbol to use to specify placeholders. Each placeholder value must have this placeholder symbol at the start and end of the placeholder. The default symbol is a dollar sign ($). For example, `$username$` or `$0$`. You can repeat the placeholder symbol to escape it. For example, `$$100` represents $100. `delimiter`. The delimiter to use to split the value when the value argument contains a string. The default value is a comma (`,`) The placeholder value is a key that links to the values in your hash, array, or string. If you use a hash, you can use string keys. If you use an array or string value, use a zero-indexed numeric key that specifies which of the listed values to use. For example: `{{ placeholderTemplate 'liftoff!,one,two,three' 'countdown: $3$, $2$, $1$, and $0$' placeholder='$' delimiter=','}}` generates the string countdown: three, two, one, and liftoff!.
`prettyPrintNumber` | Pretty-prints the specified number (for example, it converts 1000 to 1,000). You can optionally add the following parameters: `delimiter`. The thousands delimiter to use. The default value is a comma (`,`) `round`. The option to use for rounding the value. This parameter accepts the following values: `round`. Use standard rounding rules. `ceil`. Round up to the next integer. `floor`. Round down to the next integer. `N`. A number of decimal places to round to. `false`. Disable rounding. This value is the default. `plusIfPositive`. Set to true to add a plus symbol (`+`) in front of positive numbers (for example +8). The default value is false.
`regexIf` | A block helper that takes two string arguments, a regular expression and a string. The block executes if the regular expression matches the string. You can optionally add the following parameter: `flags`. Additional flags to apply to the regular expression match. For example, the flag `i` makes the matching case-insensitive. For a list of available flags, refer to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp.
`toExternalUrl` | Adds a URL schema prefix to the specified string, if it does not already have one. You can optionally add the following parameter: `defaultProtocol`. The prefix to use. The default value is `http://`.
`toLowerCase` | Converts the specified string to lower case characters.
`toUpperCase` | Converts the specified string to upper case characters.
`toRelativeTime` | Prints a specified date string as a relative time (for example, 50 years ago). You can optionally add the following parameters: `dateFormat`. The date format of the input string argument. This option takes a `moment.js` date format string. The default format is `DD-MM-YYYY`. For more information, refer to the `moment.js` documentation. `hideSuffix`. Set to true to hide the suffix (for example, to print 50 years rather than 50 years ago). The default value is false. `round`. The option to use for rounding the value. This parameter accepts the following values: `round`. Use standard mathematical rounding rules. This value is the default. `ceil`. Round up to the next integer. `floor`. Round down to the next integer. `N`. A number of decimal places to round to.
`wikiThumbnailHelper` | Converts a Wikipedia Commons image URL to one with a fixed thumbnail size. This helper takes two arguments. The first argument is the URL, and the second is the maximum thumbnail width (in pixels).

You reference fields in custom helpers by using the field ID (that is, the corresponding key in the `fieldsInfo` section of the Find configuration file). Document fields are available only if you explicitly reference them in that configuration section.

Copyright 2015-2025 Open Text
Version 25.2 | Last updated April 2025

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery Find 25.2

Topic Title: Create Template Files