Rearranged shop template page to better handle previews & template editor BOD-126
This commit is contained in:
@@ -8,9 +8,42 @@ require("dotenv").config({
|
||||
});
|
||||
var _ = require("lodash");
|
||||
const Handlebars = require("handlebars");
|
||||
var Dinero = require("dinero.js");
|
||||
Dinero.defaultCurrency = "CAD";
|
||||
Dinero.globalLocale = "en-CA";
|
||||
|
||||
//Usage: {{moment appointments_by_pk.start format="dddd, DD MMMM YYYY"}}
|
||||
|
||||
Handlebars.registerHelper("dinerof", function (context, block) {
|
||||
if (context && context.hash) {
|
||||
block = _.cloneDeep(context);
|
||||
context = undefined;
|
||||
}
|
||||
var amount = Dinero(context);
|
||||
if (context) {
|
||||
return amount.toFormat();
|
||||
}
|
||||
return "";
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("objectKeys", function (obj, block) {
|
||||
var accum = "";
|
||||
|
||||
Object.keys(obj).map((key) => {
|
||||
accum += block.fn({ key, value: obj[key] });
|
||||
});
|
||||
return accum;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("dinero", function (context, block) {
|
||||
if (context && context.hash) {
|
||||
block = _.cloneDeep(context);
|
||||
context = undefined;
|
||||
}
|
||||
var amount = Dinero({ amount: Math.round((context || 0) * 100) });
|
||||
return amount.toFormat();
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("moment", function (context, block) {
|
||||
if (context && context.hash) {
|
||||
block = _.cloneDeep(context);
|
||||
|
||||
Reference in New Issue
Block a user