<p><a href="http://squarebit.co.uk/software/craft/searchplus" rel="nofollow">Hi, Developer of Search Plus here.</a></p>

<p>Swapping out the js template engine isn't a simple thing. It certainly can be done, but it'd involve a reasonable amount of reworking to change. </p>

<p>If you're less experienced with js I wouldn't recommend it off hand. </p>

<p><strong>Instead of swapping out the javascript templating engine, I'd recommend using the <a href="http://squarebit.co.uk/software/craft/searchplus/usage/hooks-events#searchplus_alterbasicitemmapping" rel="nofollow">alterBasicMapping</a> (that's exactly what it's designed for) hook to change the actual content to the format you need <em>before</em> it's passed to algolia for indexing</strong></p>

<p>If you did want to dig in and give it a try, the first step would be to create your own clone of the bundled searchplus.js, found in the <code>/plugins/searchplus/resources/js/</code> folder. </p>

<p>Within that there are a few key parts, from line 48 you'd see the various <code>Hogan.compile</code> markers which would need changing, and then each of the separate <code>renderHits()</code>, <code>renderFacets()</code>, <code>renderPagination()</code> etc.. would need updating. </p>

<p>Most of those methods are dedicated to handling the logic, with the last lines of them finally passing the data down to Hogan, which looks like : <code>$hits.html(hitsTemplate.render(content))</code>. </p>

<p>Your swig version would replace that <code>hitsTemplate.render()</code> part. </p>

<p>Again - not something I'd directly recommend unless you're comfortable with the javascript side of things.</p>

CC BY-SA 3.0
2016-04-25T16:37:53.887Z
2016-04-25T16:37:53.887Z
Joel Bradbury
<p>For a JavaScript novice like myself, what steps would be involved in swapping out the hogan.js templating framework for something else? I have my eye on <a href="http://paularmstrong.github.io/swig/" rel="nofollow">Swig</a>, which comes with some 'twig-like' filters I need to utilize when outputting my search results.</p>

<javascript>
Swapping Hogan for other JavaScript template engine in the SearchPlus plugin
# Swapping Hogan for other JavaScript template engine in the SearchPlus plugin

(Asked by: username_0 on 2016-02-22)

For a JavaScript novice like myself, what steps would be involved in swapping out the hogan.js templating framework for something else? I have my eye on [Swig](http://paularmstrong.github.io/swig/), which comes with some 'twig-like' filters I need to utilize when outputting my search results.

**Tags:** javascript


---

## 1 answers

### Answer by username_1 on 2016-04-25. Score: 2 | Accepted answer

[Hi, Developer of Search Plus here.](http://squarebit.co.uk/software/craft/searchplus)

Swapping out the js template engine isn't a simple thing. It certainly can be done, but it'd involve a reasonable amount of reworking to change.

If you're less experienced with js I wouldn't recommend it off hand.

**Instead of swapping out the javascript templating engine, I'd recommend using the [alterBasicMapping](http://squarebit.co.uk/software/craft/searchplus/usage/hooks-events#searchplus_alterbasicitemmapping) (that's exactly what it's designed for) hook to change the actual content to the format you need *before* it's passed to algolia for indexing**

If you did want to dig in and give it a try, the first step would be to create your own clone of the bundled searchplus.js, found in the `/plugins/searchplus/resources/js/` folder.

Within that there are a few key parts, from line 48 you'd see the various `Hogan.compile` markers which would need changing, and then each of the separate `renderHits()`, `renderFacets()`, `renderPagination()` etc.. would need updating.

Most of those methods are dedicated to handling the logic, with the last lines of them finally passing the data down to Hogan, which looks like : `$hits.html(hitsTemplate.render(content))`.

Your swig version would replace that `hitsTemplate.render()` part.

Again - not something I'd directly recommend unless you're comfortable with the javascript side of things.


---

