docxtemplater
Advanced tools
Comparing version 3.45.0 to 3.45.1
@@ -42,2 +42,38 @@ const expressions = require("angular-expressions"); | ||
function getObjectIdentifiers(x, scope = {}) { | ||
if (x.expression) { | ||
getObjectIdentifiers(x.expression, scope); | ||
return scope; | ||
} | ||
if (x.body) { | ||
x.body.forEach((y) => getObjectIdentifiers(y, scope)); | ||
return scope; | ||
} | ||
if (x.type === "CallExpression") { | ||
getObjectIdentifiers(x.callee, scope); | ||
if (x.arguments) { | ||
x.arguments.forEach((y) => getObjectIdentifiers(y, scope)); | ||
} | ||
} | ||
if (x.ast) { | ||
return getObjectIdentifiers(x.ast); | ||
} | ||
if (x.left) { | ||
getObjectIdentifiers(x.left, scope); | ||
getObjectIdentifiers(x.right, scope); | ||
} | ||
if (x.type === "Identifier") { | ||
const subscope = scope[x.name] || {}; | ||
scope[x.name] = subscope; | ||
return subscope; | ||
} | ||
if (x.type === "MemberExpression") { | ||
const subscope = getObjectIdentifiers(x.object, scope); | ||
return getObjectIdentifiers(x.property, subscope); | ||
} | ||
return scope; | ||
} | ||
function getIdentifiers(x) { | ||
@@ -102,2 +138,5 @@ if (x.expression) { | ||
}, | ||
getObjectIdentifiers() { | ||
return getObjectIdentifiers(expr); | ||
}, | ||
get(scope, context) { | ||
@@ -104,0 +143,0 @@ let obj = {}; |
@@ -39,2 +39,38 @@ const expressions = require("angular-expressions"); | ||
function getObjectIdentifiers(x, scope = {}) { | ||
if (x.expression) { | ||
getObjectIdentifiers(x.expression, scope); | ||
return scope; | ||
} | ||
if (x.body) { | ||
x.body.forEach((y) => getObjectIdentifiers(y, scope)); | ||
return scope; | ||
} | ||
if (x.type === "CallExpression") { | ||
getObjectIdentifiers(x.callee, scope); | ||
if (x.arguments) { | ||
x.arguments.forEach((y) => getObjectIdentifiers(y, scope)); | ||
} | ||
} | ||
if (x.ast) { | ||
return getObjectIdentifiers(x.ast); | ||
} | ||
if (x.left) { | ||
getObjectIdentifiers(x.left, scope); | ||
getObjectIdentifiers(x.right, scope); | ||
} | ||
if (x.type === "Identifier") { | ||
const subscope = scope[x.name] || {}; | ||
scope[x.name] = subscope; | ||
return subscope; | ||
} | ||
if (x.type === "MemberExpression") { | ||
const subscope = getObjectIdentifiers(x.object, scope); | ||
return getObjectIdentifiers(x.property, subscope); | ||
} | ||
return scope; | ||
} | ||
function getIdentifiers(x) { | ||
@@ -103,2 +139,5 @@ if (x.expression) { | ||
}, | ||
getObjectIdentifiers() { | ||
return getObjectIdentifiers(expr); | ||
}, | ||
get(scope, context) { | ||
@@ -105,0 +144,0 @@ const scopeList = context.scopeList; |
@@ -42,2 +42,40 @@ "use strict"; | ||
} | ||
function _getObjectIdentifiers(x) { | ||
var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
if (x.expression) { | ||
_getObjectIdentifiers(x.expression, scope); | ||
return scope; | ||
} | ||
if (x.body) { | ||
x.body.forEach(function (y) { | ||
return _getObjectIdentifiers(y, scope); | ||
}); | ||
return scope; | ||
} | ||
if (x.type === "CallExpression") { | ||
_getObjectIdentifiers(x.callee, scope); | ||
if (x.arguments) { | ||
x.arguments.forEach(function (y) { | ||
return _getObjectIdentifiers(y, scope); | ||
}); | ||
} | ||
} | ||
if (x.ast) { | ||
return _getObjectIdentifiers(x.ast); | ||
} | ||
if (x.left) { | ||
_getObjectIdentifiers(x.left, scope); | ||
_getObjectIdentifiers(x.right, scope); | ||
} | ||
if (x.type === "Identifier") { | ||
var subscope = scope[x.name] || {}; | ||
scope[x.name] = subscope; | ||
return subscope; | ||
} | ||
if (x.type === "MemberExpression") { | ||
var _subscope = _getObjectIdentifiers(x.object, scope); | ||
return _getObjectIdentifiers(x.property, _subscope); | ||
} | ||
return scope; | ||
} | ||
function _getIdentifiers(x) { | ||
@@ -95,2 +133,5 @@ if (x.expression) { | ||
}, | ||
getObjectIdentifiers: function getObjectIdentifiers() { | ||
return _getObjectIdentifiers(expr); | ||
}, | ||
get: function get(scope, context) { | ||
@@ -97,0 +138,0 @@ var obj = {}; |
@@ -40,2 +40,40 @@ "use strict"; | ||
} | ||
function _getObjectIdentifiers(x) { | ||
var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
if (x.expression) { | ||
_getObjectIdentifiers(x.expression, scope); | ||
return scope; | ||
} | ||
if (x.body) { | ||
x.body.forEach(function (y) { | ||
return _getObjectIdentifiers(y, scope); | ||
}); | ||
return scope; | ||
} | ||
if (x.type === "CallExpression") { | ||
_getObjectIdentifiers(x.callee, scope); | ||
if (x.arguments) { | ||
x.arguments.forEach(function (y) { | ||
return _getObjectIdentifiers(y, scope); | ||
}); | ||
} | ||
} | ||
if (x.ast) { | ||
return _getObjectIdentifiers(x.ast); | ||
} | ||
if (x.left) { | ||
_getObjectIdentifiers(x.left, scope); | ||
_getObjectIdentifiers(x.right, scope); | ||
} | ||
if (x.type === "Identifier") { | ||
var subscope = scope[x.name] || {}; | ||
scope[x.name] = subscope; | ||
return subscope; | ||
} | ||
if (x.type === "MemberExpression") { | ||
var _subscope = _getObjectIdentifiers(x.object, scope); | ||
return _getObjectIdentifiers(x.property, _subscope); | ||
} | ||
return scope; | ||
} | ||
function _getIdentifiers(x) { | ||
@@ -95,2 +133,5 @@ if (x.expression) { | ||
}, | ||
getObjectIdentifiers: function getObjectIdentifiers() { | ||
return _getObjectIdentifiers(expr); | ||
}, | ||
get: function get(scope, context) { | ||
@@ -97,0 +138,0 @@ var scopeList = context.scopeList; |
@@ -9,3 +9,3 @@ "use strict"; | ||
it("should work", function () { | ||
var result = angularParser("x+x", { | ||
expect(angularParser("x+x", { | ||
tag: { | ||
@@ -19,4 +19,13 @@ value: "x+x" | ||
scopePathItem: [] | ||
}); | ||
expect(result).to.equal(2); | ||
})).to.equal(2); | ||
expect(angularParser("x(y)", { | ||
scopePath: [] | ||
}).get({ | ||
x: function x(y) { | ||
return y * 2; | ||
}, | ||
y: 3 | ||
}, { | ||
scopePathItem: [] | ||
})).to.equal(6); | ||
}); | ||
@@ -36,2 +45,40 @@ it("should work with ie 11", function () { | ||
}); | ||
it("should be able to get object identifiers", function () { | ||
expect(angularParser("(x.y.z + x.m) / a").getObjectIdentifiers()).to.deep.equal({ | ||
a: {}, | ||
x: { | ||
m: {}, | ||
y: { | ||
z: {} | ||
} | ||
} | ||
}); | ||
expect(angularParser("x(a.b.c)").getObjectIdentifiers()).to.deep.equal({ | ||
x: {}, | ||
a: { | ||
b: { | ||
c: {} | ||
} | ||
} | ||
}); | ||
}); | ||
it("should be able to get object identifiers ie11", function () { | ||
expect(angularParserIE11("(x.y.z + x.m) / a").getObjectIdentifiers()).to.deep.equal({ | ||
a: {}, | ||
x: { | ||
m: {}, | ||
y: { | ||
z: {} | ||
} | ||
} | ||
}); | ||
expect(angularParserIE11("x(a.b.c)").getObjectIdentifiers()).to.deep.equal({ | ||
x: {}, | ||
a: { | ||
b: { | ||
c: {} | ||
} | ||
} | ||
}); | ||
}); | ||
it("should be able to getIdentifiers", function () { | ||
@@ -38,0 +85,0 @@ angularParser.filters.getimg = function () { |
{ | ||
"name": "docxtemplater", | ||
"version": "3.45.0", | ||
"version": "3.45.1", | ||
"author": "Edgar Hipp", | ||
@@ -5,0 +5,0 @@ "description": "Generate docx, pptx, and xlsx from templates (Word, Powerpoint and Excel documents), from Node.js, the Browser and the command line", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1106378
22765