I don’t know if it’s the best solution, but that’s how I did it:
helpers.js
let themeHelpers = {
// Counts all elements of an array
countArray: function(arrayContent) {
if (arrayContent.constructor === Array) {
return arrayContent.length;
} else {
return 0;
}
}
};
module.exports = themeHelpers;
in the template:
{{#checkIf (countArray menus.mainMenu.items) '==' 4}}
show something...
{{/checkIf}}
Works for me…