EscapeHTML function not working

This is my code setup:

I am using a docsearch implementation to crawl my data as well.

Steps to reproduce error:

  1. Enter any search term with an apostrophe: e.g., Parkinson's
  2. Instantsearch returns the {{level}} research result with escaped HTML, e.g., Parkinsons's Disease Dementia (PDD) instead of Parkinsons's Disease Dementia (PDD)

In my app.js code I have used the escapeHTML function (line 32) and set it to false, but it does not seem to work.

  instantsearch.widgets.infiniteHits({
    container: '#infinite-hits',
    escapeHTML: false,
    templates: {
      item: `

I think the reason it isn’t working is that it has something to do with the transformItems function that I implemented (from this thread: Grouping Instantsearch results under a common hierarchy/category - #8 by haroen), unfortunately I am not super great with javascript, so am not sure how to solve this problem.

I would appreciate any help, thank you!

For those who are wondering, I found the answer to this problem from this thread: HTML encoding · Issue #1778 · algolia/instantsearch.js · GitHub

I ended up enclosing an extra set of curly braces {{level}}{{{level}}}

I have no idea how this fixed it, but it did!

@psych this is the reason why it works. handlebars.js - What does `{{{variable}}}` mean in handlebars? - Stack Overflow

1 Like