use angularParser
https://docxtemplater.readthedocs.io/en/latest/angular_parse.html
var expressions = require("angular-expressions");
function angularParser(tag) {
if (tag === ".") {
return {
get: function (s) {
return s;
}
};
}
const expr = expressions.compile(
tag.replace(/(’|‘)/g, "'").replace(/(“|”)/g, '"')
);
expressions.filters.upper = function (input) {
// This condition should be used to make sure that if your input is undefined, your output will be undefined as well and will not throw an error
if (!input) return input;
return input.toUpperCase();
};
expressions.filters.commaNum = function (input) {
// This condition should be used to make sure that if your input is undefined, your output will be undefined as well and will not throw an error
if (!input) return input;
if (!isNaN(input))
return input.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
else return input;
};
return {
get: function (scope, context) {
let obj = {};
const scopeList = context.scopeList;
const num = context.num;
for (let i = 0, len = num + 1; i < len; i++) {
obj = merge(obj, scopeList[i]);
}
return expr(scope, obj);
}
};
}
function nullGetter(part, scopeManager) {
if (!part.module) {
return " ";
}
if (part.module === "rawxml") {
return "";
}
return "";
}
var doc = new window.docxtemplater().loadZip(zip).setOptions({
linebreaks: true,
parser: angularParser,
nullGetter: nullGetter
});