|
1 | 1 | define([
|
2 | 2 | 'jquery',
|
3 | 3 | 'algoliaBundle',
|
4 |
| - 'algoliaHoganLib', |
5 |
| - 'algoliaMustacheLib', |
6 | 4 | 'algoliaTemplateEngine',
|
7 | 5 | 'Magento_Catalog/js/price-utils',
|
8 | 6 | 'algoliaCommon',
|
9 | 7 | 'algoliaInsights',
|
10 | 8 | 'algoliaHooks',
|
11 |
| -], function ($, algoliaBundle, Hogan, Mustache, templateEngine, priceUtils) { |
12 |
| - |
13 |
| - const processTemplate = (template, templateVars, useMustache = false) => { |
14 |
| - const hoganStart = performance.now(); |
15 |
| - const wrapperTemplate = Hogan.compile(template); |
16 |
| - const hoganResult = wrapperTemplate.render(templateVars); |
17 |
| - const hoganEnd = performance.now(); |
18 |
| - console.log("Hogan execution time: %s ms", hoganEnd - hoganStart); |
19 |
| - |
20 |
| - if (useMustache) { |
21 |
| - const mustacheStart = performance.now(); |
22 |
| - const mustacheResult = Mustache.render(template, templateVars); |
23 |
| - const mustacheEnd = performance.now(); |
24 |
| - console.log("Mustache execution time: %s ms", mustacheEnd - mustacheStart); |
25 |
| - return mustacheResult; |
26 |
| - } |
27 |
| - |
28 |
| - return hoganResult; |
29 |
| - }; |
30 |
| - |
| 9 | +], function ($, algoliaBundle, templateEngine, priceUtils) { |
31 | 10 | $(async function ($) {
|
| 11 | + const templateProcessor = await templateEngine.getSelectedEngineAdapter(); |
| 12 | + |
32 | 13 | /** We have nothing to do here if instantsearch is not enabled **/
|
33 | 14 | if (
|
34 | 15 | typeof algoliaConfig === 'undefined' ||
|
@@ -130,7 +111,7 @@ define([
|
130 | 111 | translations : algoliaConfig.translations,
|
131 | 112 | };
|
132 | 113 |
|
133 |
| - const wrapperHtml = await templateEngine.processTemplate(template, templateVars); |
| 114 | + const wrapperHtml = templateProcessor.process(template, templateVars); |
134 | 115 | $('.algolia-instant-selector-results').html(wrapperHtml).show();
|
135 | 116 |
|
136 | 117 | /**
|
@@ -375,7 +356,7 @@ define([
|
375 | 356 | }
|
376 | 357 |
|
377 | 358 | const template = $('#instant-stats-template').html();
|
378 |
| - return processTemplate(template, data, true); |
| 359 | + return templateProcessor.process(template, data); |
379 | 360 | },
|
380 | 361 | },
|
381 | 362 | },
|
|
0 commit comments