Formats a clickable HTML link (<a>
).
href
: The link URIoptions
: Optional. The options to use (see IAnchorUtilsOptions)Formats a currency value to a string using the specified options.
content
: The number value to format.options
: Optional. The options to use (see ICurrencyToStringOptions).Formats a date value to a date-only string using the specified options.
content
: The Date value to format.options
: Optional. The options to use (see IDateToStringOptions).Formats a date value to a date and time string using the specified options.
content
: The Date value to format.options
: Optional. The options to use (see IDateToStringOptions).Renders one or several email values in mailto:
hyperlinks.
value
: The string or array of strings that contains a list of semicolon-separated email
values. When multiple values are passed, each value is displayed in a
separate hyperlink.companyDomain
: Optional. The string that contains your own domain (e.g.:
coveo.com). When specified, this parameter allows email addresses
coming from your own domain to be displayed in a shortened format
(e.g.: Full Name), whereas email addresses coming from an external
domain will be displayed in an extended format (e.g.: Full Name
(domain.com)). If this parameter is not specified, then the shortened
format will automatically be used.me
: Optional. The string that contains the current username. If it is
specified, then the email address containing the current username will
be replaced by the localized string 'Me'.lengthLimit
: Optional. The number of email addresses that you want to display
before an ellipse is added (e.g.: 'From Joe, John and 5 others').truncateName
: Optional. When the username is available from the email address,
then you can specify if you want to truncate the full name. (e.g.:
'John S.' instead of 'John Smith').false
.Formats a date value to a date and time string using options suitable for email dates
content
: The Date value to format.options
: Optional. The options to use (see IDateToStringOptions).Replace all carriage return in a string by a <br /> tag
value
: The string value to replace the carriage returns in.Generates an icon based on the file type of the current result. The icon
will be contained inside a <span>
element with the appropriate CSS
class.
result
: Optional. The current result object inside your template. In
underscore, it is referenced as obj
. By default, the result
will be resolved automatically from your current template function (
Meaning the nearest result in the current call stack execution inside
your template)options
: Optional. The options to use (see IIconOptions).Highlights a string using the provided highlight information.
content
: The URI to shorten.highlights
: Optional. The highlight information to use.cssClass
: Optional. The name of the CSS class to use for highlighting.This helper operates exactly like the highlightStreamText helper, except that it should be used to highlight HTML content. The helper takes care of not highlighting the HTML markup.
content
: The string content to highlighttermsToHighlight
: The terms to highlight (see IHighlightTerm)phraseToHighlight
: The phrases to highlight (see IHighlightPhrase)options
: Optional. The options defined below as IStreamHighlightOptionsNote:
highlightStreamHTML
should only be used for very particular/specific use cases (e.g., augmenting the result template with additional information rather than the typical excerpt/title), and is not a proper replacement for actually having the correct title and excerpt on your results.Using incorrect result titles or excerpts on your search interface also causes relevancy to suffer greatly, as the index uses the title and excerpt to find relevant results. Consequently, end users are more likely to see results whose titles do not match their query.
Moreover, the recommended method to implement simple title and/or excerpt highlighting is to simply use the Excerpt and ResultLink components.
Highlights the provided terms in a given string.
By default, the terms to highlight are the current query and the
associated stemming words from the index.
The only required parameter is the content, which specify the string that needs to be highlighted.
The other parameters will normally be automatically resolved for you from the current result object.
content
: The string content to highlighttermsToHighlight
: The terms to highlight (see IHighlightTerm)phraseToHighlight
: The phrases to highlight (see IHighlightPhrase)options
: Optional. The options defined below as IStreamHighlightOptionsNote:
highlightStreamText
should only be used for very particular/specific use cases (e.g., augmenting the result template with additional information rather than the typical excerpt/title), and is not a proper replacement for actually having the correct title and excerpt on your results.Using incorrect result titles or excerpts on your search interface also causes relevancy to suffer greatly, as the index uses the title and excerpt to find relevant results. Consequently, end users are more likely to see results whose titles do not match their query.
Moreover, the recommended method to implement simple title and/or excerpt highlighting is to simply use the Excerpt and ResultLink components.
Formats an HTML image tag (<img>
).
src
: The image source URIoptions
: Optional. The options to use (see IImageUtilsOptions)Detect if the results is being rendered in a mobile device.
If it's not a mobile device, the helper return null ;
If it's a mobile device, return the type of device (Android, iPhone, iPad) etc.
Loads a partial template in the current template, by passing the ID of the template to load, the condition for which this template should be loaded, and the context object (the object that the loaded template will use as its data). By default, the context object will be the same as the template that called this helper function. So, for example, in a ResultList Component, the contextObject would, by default, be the Query Results.
templateId
: The ID of the template to load.condition
: Optional. The boolean condition to determine if this template should
load for this result set. Most of the time this would be a condition of
the type if raw.somefield == 'something'.contextObject
: Optional. The object that should be used by the loaded template
as its contextObject.Formats a numeric value using the format string.
content
: The numeric value to format.format
Optional. The string format to use. See the Globalize library for the list of available formats.When the helper is used in a FieldValue
component, this value is automatically retrieved from the specified field
.
Example:
<div class="CoveoFieldValue" data-field="@viewcount" data-text-caption="Views" data-helper="number" data-helper-options-format="n0"></div>
Shortens a string so that its length does not exceed a specific number of characters. An ellipsis is appended to the string if it exceeds the maximum length.
content
: The string to shorten.length
: The maximum length of the resulting string.highlights
: Optional. If provided, the string will be highlighted
using this highlight information.cssClass
: Optional. When highlighting, the name of the CSS class to use.Shortens a string using an algorithm suitable for file paths. The helper will insert an ellipsis in the string where text has been removed when the path exceeds the maximum length.
content
: The path to shorten.length
: The maximum length of the resulting string.highlights
: Optional. If provided, the string will be highlighted using
this highlight information.cssClass
: Optional. When highlighting, the name of the CSS class to use.Shortens a string using an algorithm suitable for URIs. The helper will insert an ellipsis in the string where text has been removed when the URI exceeds the maximum length.
content
: The URI to shorten.length
: The maximum length of the resulting string.highlights
: Optional. If provided, the string will be highlighted
using this highlight information.cssClass
: Optional. When highlighting, the name of the CSS class to use.Formats a number, which represents a file size in bytes, into a logical unit size.
Examples:
size(1024) => 1024 B
size(1025) => 1 KB
size(10240) => 10 KB
Examples:
HTML
<div class="CoveoFieldValue" data-field='@size' data-helper="size" data-helper-options-base="1"></div>
Underscore
<%= size(raw.size, {base: 0, precision: 2}) %>
value
: The number to formatoptions
: The options to use (see ISizeOptions)Formats an HTML image tag (<img>
), and automatically uses the result
object to query the REST API to get the thumbnail for this result. For
example, this can be used to great effect when designing a template
showing users or previews of files.
result
: Optional. The current result object inside your template. In
underscore, it is referenced as obj
. By default, the result
will be resolved automatically from your current template function (
Meaning the nearest result in the current call stack execution inside
your template)endpoint
: Optional. The name of the endpoint to use for your
thumbnail. Default is default.options
: Optional. The options to use (see IImageUtilsOptions).Formats a date value to a time-only string using the specified options.
content
: The Date value to format.options
: Optional. The options to use (see IDateToStringOptions).Given a number, either in millisecond or second, convert to a HH:MM:SS format.
Examples
timeSpan(1, {isMilliseconds: false}) => '00:01'
timeSpan(1000, {isMilliseconds: true}) => '00:01'
value
: The number to convert to a timespanoptions
: The options to use (see ITimeSpanUtilsOptions)Given a filetype value, try to return a translated and human readable version.
If the filetype is known and recognized by the framework, a translated value will be returned.
Examples
translatedCaption('doc') => Document
translatedCaption('xls') => Spreadsheet Document
value
: The string value to translate
The core template helpers provided by default.
Examples:
HTML
<div class="CoveoFieldValue" data-field="@videoduration" data-helper="timeSpan" data-helper-options-is-milliseconds="false"></div>
Underscore
<%= timeSpan(raw.videoduration, { isMilliseconds: false }) %>