Skip to end of metadata
Go to start of metadata

You can format your search results using Underscore templates (see Underscore.js). They can use Coveo Result Template Helpers or execute any arbitrary JavaScript function available in the page. Choose to use an Underscore result template over HTML Result Template when you need the added flexibility of JavaScript functions. 

Generic Underscore result template example

Precision on the delimiters


While reading the Underscore template engine documentation (see Underscore.js), you might notice that you can modify the delimiter (<% %>) to something else by changing the _.templateSettings object.

In an .aspx page, <% %> will be interpreted as run this on the server.

This would normally be a problem, and you might be tempted to override this setting to something else. However, the Coveo JavaScript Search Framework uses those delimiters internally, and if you override them, the underlying components won't render correctly. By default, we use a bit of regex magic to support both <% %> and {{ }} style delimiters. So before attempting to customize those delimiters, make sure that you understand the impacts.




  • No labels