|
|
@ -1,5 +1,5 @@ |
|
|
const handlebars = require("handlebars") |
|
|
const handlebars = require("handlebars") |
|
|
const { registerAll } = require("./helpers/index") |
|
|
const { registerAll, registerMinimum } = require("./helpers/index") |
|
|
const processors = require("./processors") |
|
|
const processors = require("./processors") |
|
|
const { atob, btoa } = require("./utilities") |
|
|
const { atob, btoa } = require("./utilities") |
|
|
const manifest = require("../manifest.json") |
|
|
const manifest = require("../manifest.json") |
|
|
@ -8,6 +8,7 @@ const { FIND_HBS_REGEX, FIND_DOUBLE_HBS_REGEX } = require("./utilities") |
|
|
const hbsInstance = handlebars.create() |
|
|
const hbsInstance = handlebars.create() |
|
|
registerAll(hbsInstance) |
|
|
registerAll(hbsInstance) |
|
|
const hbsInstanceNoHelpers = handlebars.create() |
|
|
const hbsInstanceNoHelpers = handlebars.create() |
|
|
|
|
|
registerMinimum(hbsInstanceNoHelpers) |
|
|
const defaultOpts = { noHelpers: false, noEscaping: false } |
|
|
const defaultOpts = { noHelpers: false, noEscaping: false } |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -105,9 +106,7 @@ module.exports.processStringSync = (string, context, opts) => { |
|
|
throw "Cannot process non-string types." |
|
|
throw "Cannot process non-string types." |
|
|
} |
|
|
} |
|
|
try { |
|
|
try { |
|
|
// finalising adds a helper, can't do this with no helpers
|
|
|
string = processors.preprocess(string, opts) |
|
|
const shouldFinalise = !opts.noHelpers |
|
|
|
|
|
string = processors.preprocess(string, shouldFinalise) |
|
|
|
|
|
// this does not throw an error when template can't be fulfilled, have to try correct beforehand
|
|
|
// this does not throw an error when template can't be fulfilled, have to try correct beforehand
|
|
|
const instance = opts.noHelpers ? hbsInstanceNoHelpers : hbsInstance |
|
|
const instance = opts.noHelpers ? hbsInstanceNoHelpers : hbsInstance |
|
|
const templateString = |
|
|
const templateString = |
|
|
@ -119,8 +118,10 @@ module.exports.processStringSync = (string, context, opts) => { |
|
|
return processors.postprocess( |
|
|
return processors.postprocess( |
|
|
template({ |
|
|
template({ |
|
|
now: new Date(now).toISOString(), |
|
|
now: new Date(now).toISOString(), |
|
|
|
|
|
__opts: opts, |
|
|
...context, |
|
|
...context, |
|
|
}) |
|
|
}), |
|
|
|
|
|
{ escapeNewlines: opts ? opts.escapeNewlines : false } |
|
|
) |
|
|
) |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
return input |
|
|
return input |
|
|
|