3

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, which comes with some 'twig-like' filters I need to utilize when outputting my search results.

2

Hi, Developer of Search Plus here.

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 (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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.