lx-scan
Version:
License eXtension to find 5-tuples of all installed packages: name, version, project home page, license (e. g. Apache v2, BSD) and required notice. It includes a GUI to edit information for each package and to enter information if necessary.
87 lines (74 loc) • 1.92 kB
JavaScript
var hbs = require('hbs');
var package_count = 0;
hbs.registerHelper("resCount", function() {
package_count = 0;
});
hbs.registerHelper('ifObject', function(item, options) {
if(typeof item === "object") {
return options.fn(this);
} else {
return options.inverse(this);
}
});
hbs.registerHelper("math", function(lvalue, operator, rvalue, options) {
lvalue = parseFloat(lvalue);
rvalue = parseFloat(rvalue);
return {
"+": lvalue + rvalue,
"-": lvalue - rvalue,
"*": lvalue * rvalue,
"/": lvalue / rvalue,
"%": lvalue % rvalue
}[operator];
});
hbs.registerHelper("ifmod", function(lvalue,rvalue,mod,options) {
lvalue = parseFloat(lvalue);
rvalue = parseFloat(rvalue);
var val = package_count - 1 - rvalue;
if(!(val % parseFloat(mod))) {
return options.fn(this);
} else {
return options.inverse(this);
};
});
hbs.registerHelper("ifmod2",function(lvalue,rvalue,mod,options) {
lvalue = parseFloat(lvalue);
rvalue = parseFloat(rvalue);
mod = parseFloat(mod);
var val = (lvalue - rvalue) % mod;
if(val < 0)
val = mod + val;
if(!val) {
return options.fn(this);
} else {
return options.inverse(this);
}
});
hbs.registerHelper("2cif", function (condi1,condi2,options) {
if(condi1) {
if(!condi2) {
package_count+=1;
return options.fn(this);
}
}
if(!condi1) {
package_count+=1;
return options.fn(this);
}
});
hbs.registerHelper("n2cif", function (condi1,condi2,options) {
if(!(condi1)) {
if(!condi2) {
return options.fn(this);
}
}
if(condi1) {
return options.inverse(this);
}
});
hbs.registerHelper('breaklines', function(text) {
var text = hbs.Utils.escapeExpression(text);
text = text.replace(/(\r\n|\n|\r)/gm, '<br>');
return new hbs.SafeString(text);
});
module.exports = hbs;