From df213fba3f02c0d2f6c26a77ca7aab1a890782af Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Mon, 18 Jun 2018 03:35:57 +0200 Subject: [PATCH] [enh] add handlebars 'eq' and 'in' helpers --- src/js/yunohost/main.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/js/yunohost/main.js b/src/js/yunohost/main.js index fd566a82..be18e2f5 100644 --- a/src/js/yunohost/main.js +++ b/src/js/yunohost/main.js @@ -60,6 +60,21 @@ + ''); }); + // equality stuff because mustache/Handlebars is lame + // source https://stackoverflow.com/a/31632215 + Handlebars.registerHelper('eq', function(a, b) { + return a === b; + }); + + Handlebars.registerHelper('in', function(a) { + // skip first one + for (var i = 1; i < arguments.length; ++i) { + if (arguments[i] == a) + return true; + } + return false; + }); + // Look for supported type of storage to use /** * http://sammyjs.org/docs/api/0.7.4/all#Sammy.Store.LocalStorage