From 97786880b5e10ee2a27e48657d71f9cc640b8b87 Mon Sep 17 00:00:00 2001 From: Aubrey Hewes Date: Tue, 11 Dec 2018 15:58:05 +0100 Subject: [PATCH 1/4] wip for supporting higher handlebars versions --- .babelrc | 1 - .eslintrc | 15 --- README.md | 12 +- package.json | 33 +++++- src/inc/HandlebarsAST.js | 249 +++++++++++++++++++++++++++++++++++++++ src/index.js | 185 ++++++----------------------- yarn.lock | 225 ++++++++++++++++++++++++++++------- 7 files changed, 501 insertions(+), 219 deletions(-) delete mode 100644 .babelrc delete mode 100644 .eslintrc create mode 100644 src/inc/HandlebarsAST.js diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 7a870ac..0000000 --- a/.babelrc +++ /dev/null @@ -1 +0,0 @@ -{ "presets": ["es2015"] } \ No newline at end of file diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 1d77f3c..0000000 --- a/.eslintrc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "kingsquare", - "env": { - "browser": true, - "node": true - }, - "globals": { - "App": false, - "Ext": false, - "config": false - }, - "rules": { - "prefer-rest-params": [0] - } -} diff --git a/README.md b/README.md index 1731149..01934d9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![wercker status](https://app.wercker.com/status/0d5d25d4c12cbdfc395f363a2684a6a4/s/master "wercker status")](https://app.wercker.com/project/byKey/0d5d25d4c12cbdfc395f363a2684a6a4) + # communibase-template-data-factory Enrich Communibase-data in any way possible for easy use in dynamic templates. @@ -28,13 +30,3 @@ __stxt__: a Javascript-object containing optional translations, e.g.: Extra (custom) serializers can be added to the factory using the `addSerializers`-method. See serializers in the `entityType`-folder for examples and implementations - -## Debugging? - -See runTest.js line 44, attach a debugger from the IDE to mocha - - ### PLEASE NOTE ### - - This library is compatible with Handlebars 2.0.0 - - Later versions of Handlebars have a different AST and do not function properly! diff --git a/package.json b/package.json index d30df4d..cf6aaa5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "communibase-template-data-factory", - "version": "2.0.13", + "version": "3.0.0", "description": "Helper methods for working with Templates and the Communibase service.", "scripts": { "test": "mocha $NODE_DEBUG_OPTION test/tests/**/*.js", @@ -20,25 +20,50 @@ "dependencies": { "bluebird": "^3.5.1", "communibase-connector-js": "^0.5.16", - "handlebars": "^2.0.0", + "handlebars": ">=2.0.0 <= 4", "lodash": "^4.17.4", "moment": "^2.19.2" }, "devDependencies": { "Communibase": "git+ssh://git@bitbucket.org/communibase/api.git", "babel-cli": "^6.26.0", - "babel-preset-es2015": "^6.24.1", + "babel-preset-env": "^1.7.0", "bson-stream": "0.0.8", "eslint": "^5.9.0", "eslint-config-kingsquare": "^5.0.5", "grunt": "^1.0.1", "grunt-shell": "^2.1.0", + "handlebars-v2": "npm:handlebars@2.0.0", + "handlebars-v3": "npm:handlebars@3.0.3", + "handlebars-v4": "npm:handlebars@4.0.12", "kingsquare-handlebars-helpers": "^1.1.8", "mocha": "^5.2.0", "mongodb": "^2.2.24", "prettier": "^1.15.2" }, + "eslintConfig": { + "extends": "kingsquare", + "env": { + "browser": true, + "node": true + }, + "globals": { + "App": false, + "Ext": false, + "config": false + }, + "rules": { + "prefer-rest-params": [ + 0 + ] + } + }, + "babel": { + "presets": [ + "env" + ] + }, "engines": { - "node": ">=8.3.0" + "node": "^8.3.0" } } diff --git a/src/inc/HandlebarsAST.js b/src/inc/HandlebarsAST.js new file mode 100644 index 0000000..d9230cb --- /dev/null +++ b/src/inc/HandlebarsAST.js @@ -0,0 +1,249 @@ +const uniq = require("lodash/uniq"); + +const debug = false; + +const isHelper = function(node) { + // In v2 we had helper hints in the AST (`node.isHelper`).. + if (typeof node.isHelper !== "undefined") { + return node.isHelper; + } + // in v4 this information is not available in the AST so we need to + // check this our self... To do this we use the following code taken from + // https://github.com/wycats/handlebars.js/blob/95d84badcae89aa72a6f1433b851304700320920/lib/handlebars/compiler/ast.js + return (node.type === 'SubExpression') + || ((node.type === 'MustacheStatement' || node.type === 'BlockStatement') + && !!((node.params && node.params.length) || node.hash)); +}; + +module.exports.getV2Paths = (node) => { + let result = []; + + if (!node || !node.type) { + return result; + } + + let blockKeys; + switch (node.type.toLowerCase()) { + // E.g. 'date' / 'debtor.debtorNumber' + case "id": + result.push(node.idName); + break; + + case "program": + node.statements.forEach(statement => { + this.getV2Paths(statement).forEach(variable => { + result.push(variable); + }); + }); + break; + + // E.g. #each / #if / #compare / '#invoiceItems' / '#ifIsCredit' + case "block": + blockKeys = this.getV2Paths(node.mustache); + + if ( + (!isHelper(node.mustache) || node.mustache.id.string === "each") && + node.program + ) { + this.getV2Paths(node.program).forEach(subValue => { + result.push(`${blockKeys[0]}.#.${subValue}`); + }); + break; + } + + if (node.mustache.id.string === "filter") { + // look for used properties in equation + [ + node.mustache.params[1], + node.mustache.params[node.mustache.params.length === 4 ? 3 : 2] + ].forEach(possiblePropertyNode => { + switch (possiblePropertyNode.type) { + case "STRING": + // e.g. ../session.personId + result.push(`${blockKeys[0]}.#.${possiblePropertyNode.string}`); + break; + + case "ID": + // e.g. personId + result.push(possiblePropertyNode.string); + break; + } + }); + + this.getV2Paths(node.program).forEach(subValue => { + // indexes may change due to filtering: always request __all__ subValues + result.push( + subValue.replace(/^results\.(\d+|#)\./, `${blockKeys[0]}.#.`) + ); + }); + break; + } + + result = blockKeys; + + if (node.program) { + this.getV2Paths(node.program).forEach(variable => { + result.push(variable); + }); + } + if (node.inverse) { + this.getV2Paths(node.inverse).forEach(variable => { + result.push(variable); + }); + } + break; + + // E.g. '{{#compare person.gender 'M'}}' + case "mustache": + if (!isHelper(node)) { + result.push(node.id.idName); + break; + } + + node.params.forEach(param => { + this.getV2Paths(param).forEach(variable => { + result.push(variable); + }); + }); + break; + } + + return result; +}; + +module.exports.getV4Paths = (node) => { + let result = []; + if (!node || !node.type) { + return result; + } + let blockKeys; + switch (node.type) { + case "Program": + node.body.forEach(item => { + this.getV4Paths(item).forEach(variable => { + result.push(variable); + }); + }); + break; + case 'BlockStatement': + // const blockKeys = node.params.map(param => this.getV4Paths(param)); + blockKeys = []; + node.params.forEach(param => { + this.getV4Paths(param).forEach(variable => { + blockKeys.push(variable); + }); + }); + + if ((!isHelper(node) || (node.path && node.path.original === 'each')) && node.program) { + this.getV4Paths(node.program).forEach(subValue => { + result.push(`${blockKeys[0]}.#.${subValue}`); + }); + break; + } + + if (node.path && node.path.original === 'filter') { + var d = true; + // look for used properties in equation + [ + node.params[1], + node.params[node.params.length === 4 ? 3 : 2] + ].forEach(possiblePropertyNode => { + switch (possiblePropertyNode.type) { + case "StringLiteral": + // e.g. ../session.personId + result.push(`${blockKeys[0]}.#.${possiblePropertyNode.original}`); + break; + + // @ TODO BooleanLiteral ? + // @ TODO the following + case "ID": + // e.g. personId + result.push(possiblePropertyNode.original); + break; + } + }); + + if (node.program) { + this.getV4Paths(node.program).forEach(subValue => { + // indexes may change due to filtering: always request __all__ subValues + result.push( + subValue.replace(/^results\.(\d+|#)\./, `${blockKeys[0]}.#.`) + ); + }); + } + break; + } + + result = blockKeys; + // if (node.path) { + // result = this.getV4Paths(node.path); + // } + + if (node.program) { + this.getV4Paths(node.program).forEach(variable => { + result.push(variable); + }); + } + + if (node.inverse) { + this.getV4Paths(node.inverse).forEach(variable => { + result.push(variable); + }); + } + break; + + case 'MustacheStatement': + if (!isHelper(node)) { + result.push(node.path.original); + } + + if (node.params) { + node.params.forEach(param => { + this.getV4Paths(param).forEach(variable => { + result.push(variable); + }); + }); + } + break; + case "PathExpression": + result.push(node.original); + break; + } + return result; +}; + +/** + * Gets all requested paths based on the given template. When inserting: + * {{invoiceNumber}} - {{#invoiceItems}} {{totalEx}} {{/invoiceItems}} + * It should return: + * ["invoiceNumber", "invoiceItems.#.totalEx"] + * + * This supports Handlebars >=2.0.0 <=4 + * + * @param {object} node + * + * @returns {Array} result - The requested paths + */ +module.exports.getTemplatePaths = (node) => { + if (debug) { + // eslint-disable-next-line no-console + console.log(`${JSON.stringify(node)}\n\n`); + } + + let paths = []; + + // v2 + if (node.statements) { + paths = this.getV2Paths(node); + } + + // v3 / v4 + if (node.body) { + paths = this.getV4Paths(node); + } + + if (debug) { + console.log(uniq(paths)); + } + return uniq(paths); +}; diff --git a/src/index.js b/src/index.js index dfdfff6..22a5702 100755 --- a/src/index.js +++ b/src/index.js @@ -1,117 +1,6 @@ /* eslint-disable global-require */ const Promise = require("bluebird"); -const _ = require("lodash"); - -let debug = false; - -/** - * Gets all requested paths based on the given template. When inserting: - * {{invoiceNumber}} - {{#invoiceItems}} {{totalEx}} {{/invoiceItems}} - * It should return: - * ["invoiceNumber", "invoiceItems.#.totalEx"] - * - * @param {object} node - * @returns {Array} result - The requested paths - */ -function _getPaths(node) { - let result = []; - if (debug) { - // eslint-disable-next-line no-console - console.log(`${JSON.stringify(node)}\n\n`); - } - - if (!node || !node.type) { - return result; - } - - let blockKeys; - switch (node.type.toLowerCase()) { - // E.g. 'date' / 'debtor.debtorNumber' - case "id": - result.push(node.idName); - break; - - case "program": - node.statements.forEach(statement => { - _getPaths(statement).forEach(variable => { - result.push(variable); - }); - }); - break; - - // E.g. #each / #if / #compare / '#invoiceItems' / '#ifIsCredit' - case "block": - blockKeys = _getPaths(node.mustache); - - if ( - (!node.mustache.isHelper || node.mustache.id.string === "each") && - node.program - ) { - _getPaths(node.program).forEach(subValue => { - result.push(`${blockKeys[0]}.#.${subValue}`); - }); - break; - } - - if (node.mustache.id.string === "filter") { - // look for used properties in equation - [ - node.mustache.params[1], - node.mustache.params[node.mustache.params.length === 4 ? 3 : 2] - ].forEach(possiblePropertyNode => { - switch (possiblePropertyNode.type) { - case "STRING": - // e.g. ../session.personId - result.push(`${blockKeys[0]}.#.${possiblePropertyNode.string}`); - break; - - case "ID": - // e.g. personId - result.push(possiblePropertyNode.string); - break; - } - }); - - _getPaths(node.program).forEach(subValue => { - // indexes may change due to filtering: always request __all__ subValues - result.push( - subValue.replace(/^results\.(\d+|#)\./, `${blockKeys[0]}.#.`) - ); - }); - break; - } - - result = blockKeys; - - if (node.program) { - _getPaths(node.program).forEach(variable => { - result.push(variable); - }); - } - if (node.inverse) { - _getPaths(node.inverse).forEach(variable => { - result.push(variable); - }); - } - break; - - // E.g. '{{#compare person.gender 'M'}}' - case "mustache": - if (!node.isHelper) { - result.push(node.id.idName); - break; - } - - node.params.forEach(param => { - _getPaths(param).forEach(variable => { - result.push(variable); - }); - }); - break; - } - - return result; -} +const { getTemplatePaths } = require("./inc/HandlebarsAST"); const entitySerializers = { Base: require("./entityType/Base.js"), @@ -310,46 +199,44 @@ module.exports = function exports(config) { this.getPaths = function getPaths(node) { // sanitize paths - return _.uniq( - _getPaths(node).map(path => { - // find and process parent references - const newPath = []; - // trim and split - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim + dots - const nibbles = path - .replace(/^[\s\uFEFF\xA0.]+|[\s\uFEFF\xA0.]+$/g, "") - .split("."); - for (let i = 0; i < nibbles.length; i += 1) { - let currentNibble = nibbles[i]; - - // detect '..' - let parentRequested = - currentNibble === "" && - nibbles.length >= i + 2 && - nibbles[i + 1] === "" && - nibbles[i + 2].indexOf("/") === 0; - while (parentRequested) { - // traverse to parent... - const poppedNibble = newPath.pop(); - // parent is array iterator? - if (poppedNibble.match(/^(#|\d+)$/) !== null) { - newPath.pop(); - } + return getTemplatePaths(node).map(path => { + // find and process parent references + const newPath = []; + // trim and split + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim + dots + const nibbles = path + .replace(/^[\s\uFEFF\xA0.]+|[\s\uFEFF\xA0.]+$/g, "") + .split("."); + for (let i = 0; i < nibbles.length; i += 1) { + let currentNibble = nibbles[i]; + + // detect '..' + let parentRequested = + currentNibble === "" && + nibbles.length >= i + 2 && + nibbles[i + 1] === "" && + nibbles[i + 2].indexOf("/") === 0; + while (parentRequested) { + // traverse to parent... + const poppedNibble = newPath.pop(); + // parent is array iterator? + if (poppedNibble.match(/^(#|\d+)$/) !== null) { + newPath.pop(); + } - i += 2; - // more parent refs coming... - if (nibbles[i] === "/") { - nibbles[i] = ""; - } else { - currentNibble = nibbles[i].substr(1); - parentRequested = false; - } + i += 2; + // more parent refs coming... + if (nibbles[i] === "/") { + nibbles[i] = ""; + } else { + currentNibble = nibbles[i].substr(1); + parentRequested = false; } - newPath.push(currentNibble); } - return newPath.join("."); - }) - ); + newPath.push(currentNibble); + } + return newPath.join("."); + }); }; this.setStxt = function setStxt(stxt) { diff --git a/yarn.lock b/yarn.lock index d65b920..c564a7f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -484,6 +484,15 @@ babel-generator@^6.26.0: source-map "^0.5.6" trim-right "^1.0.1" +babel-helper-builder-binary-assignment-operator-visitor@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz#cce4517ada356f4220bcae8a02c2b346f9a56664" + integrity sha1-zORReto1b0IgvK6KAsKzRvmlZmQ= + dependencies: + babel-helper-explode-assignable-expression "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + babel-helper-call-delegate@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz#ece6aacddc76e41c3461f88bfc575bd0daa2df8d" @@ -502,6 +511,15 @@ babel-helper-define-map@^6.24.1: babel-types "^6.26.0" lodash "^4.17.4" +babel-helper-explode-assignable-expression@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz#f25b82cf7dc10433c55f70592d5746400ac22caa" + integrity sha1-8luCz33BBDPFX3BZLVdGQArCLKo= + dependencies: + babel-runtime "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + babel-helper-function-name@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" @@ -541,6 +559,17 @@ babel-helper-regex@^6.24.1: babel-types "^6.26.0" lodash "^4.17.4" +babel-helper-remap-async-to-generator@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz#5ec581827ad723fecdd381f1c928390676e4551b" + integrity sha1-XsWBgnrXI/7N04HxySg5BnbkVRs= + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + babel-helper-replace-supers@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz#bf6dbfe43938d17369a213ca8a8bf74b6a90ab1a" @@ -571,6 +600,30 @@ babel-plugin-check-es2015-constants@^6.22.0: dependencies: babel-runtime "^6.22.0" +babel-plugin-syntax-async-functions@^6.8.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" + integrity sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU= + +babel-plugin-syntax-exponentiation-operator@^6.8.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de" + integrity sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4= + +babel-plugin-syntax-trailing-function-commas@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3" + integrity sha1-ugNgk3+NBuQBgKQ/4NVhb/9TLPM= + +babel-plugin-transform-async-to-generator@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761" + integrity sha1-ZTbjeK/2yx1VF6wOQOs+n8jQh2E= + dependencies: + babel-helper-remap-async-to-generator "^6.24.1" + babel-plugin-syntax-async-functions "^6.8.0" + babel-runtime "^6.22.0" + babel-plugin-transform-es2015-arrow-functions@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz#452692cb711d5f79dc7f85e440ce41b9f244d221" @@ -583,9 +636,10 @@ babel-plugin-transform-es2015-block-scoped-functions@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-block-scoping@^6.24.1: +babel-plugin-transform-es2015-block-scoping@^6.23.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz#d70f5299c1308d05c12f463813b0a09e73b1895f" + integrity sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8= dependencies: babel-runtime "^6.26.0" babel-template "^6.26.0" @@ -593,9 +647,10 @@ babel-plugin-transform-es2015-block-scoping@^6.24.1: babel-types "^6.26.0" lodash "^4.17.4" -babel-plugin-transform-es2015-classes@^6.24.1: +babel-plugin-transform-es2015-classes@^6.23.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz#5a4c58a50c9c9461e564b4b2a3bfabc97a2584db" + integrity sha1-WkxYpQyclGHlZLSyo7+ryXolhNs= dependencies: babel-helper-define-map "^6.24.1" babel-helper-function-name "^6.24.1" @@ -607,35 +662,40 @@ babel-plugin-transform-es2015-classes@^6.24.1: babel-traverse "^6.24.1" babel-types "^6.24.1" -babel-plugin-transform-es2015-computed-properties@^6.24.1: +babel-plugin-transform-es2015-computed-properties@^6.22.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz#6fe2a8d16895d5634f4cd999b6d3480a308159b3" + integrity sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM= dependencies: babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-plugin-transform-es2015-destructuring@^6.22.0: +babel-plugin-transform-es2015-destructuring@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz#997bb1f1ab967f682d2b0876fe358d60e765c56d" + integrity sha1-mXux8auWf2gtKwh2/jWNYOdlxW0= dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-duplicate-keys@^6.24.1: +babel-plugin-transform-es2015-duplicate-keys@^6.22.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz#73eb3d310ca969e3ef9ec91c53741a6f1576423e" + integrity sha1-c+s9MQypaePvnskcU3QabxV2Qj4= dependencies: babel-runtime "^6.22.0" babel-types "^6.24.1" -babel-plugin-transform-es2015-for-of@^6.22.0: +babel-plugin-transform-es2015-for-of@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz#f47c95b2b613df1d3ecc2fdb7573623c75248691" + integrity sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE= dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-function-name@^6.24.1: +babel-plugin-transform-es2015-function-name@^6.22.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz#834c89853bc36b1af0f3a4c5dbaa94fd8eacaa8b" + integrity sha1-g0yJhTvDaxrw86TF26qU/Y6sqos= dependencies: babel-helper-function-name "^6.24.1" babel-runtime "^6.22.0" @@ -647,14 +707,25 @@ babel-plugin-transform-es2015-literals@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-modules-amd@^6.24.1: +babel-plugin-transform-es2015-modules-amd@^6.22.0, babel-plugin-transform-es2015-modules-amd@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz#3b3e54017239842d6d19c3011c4bd2f00a00d154" + integrity sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ= dependencies: babel-plugin-transform-es2015-modules-commonjs "^6.24.1" babel-runtime "^6.22.0" babel-template "^6.24.1" +babel-plugin-transform-es2015-modules-commonjs@^6.23.0: + version "6.26.2" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz#58a793863a9e7ca870bdc5a881117ffac27db6f3" + integrity sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q== + dependencies: + babel-plugin-transform-strict-mode "^6.24.1" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-types "^6.26.0" + babel-plugin-transform-es2015-modules-commonjs@^6.24.1: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz#0d8394029b7dc6abe1a97ef181e00758dd2e5d8a" @@ -664,32 +735,36 @@ babel-plugin-transform-es2015-modules-commonjs@^6.24.1: babel-template "^6.26.0" babel-types "^6.26.0" -babel-plugin-transform-es2015-modules-systemjs@^6.24.1: +babel-plugin-transform-es2015-modules-systemjs@^6.23.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23" + integrity sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM= dependencies: babel-helper-hoist-variables "^6.24.1" babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-plugin-transform-es2015-modules-umd@^6.24.1: +babel-plugin-transform-es2015-modules-umd@^6.23.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz#ac997e6285cd18ed6176adb607d602344ad38468" + integrity sha1-rJl+YoXNGO1hdq22B9YCNErThGg= dependencies: babel-plugin-transform-es2015-modules-amd "^6.24.1" babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-plugin-transform-es2015-object-super@^6.24.1: +babel-plugin-transform-es2015-object-super@^6.22.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz#24cef69ae21cb83a7f8603dad021f572eb278f8d" + integrity sha1-JM72muIcuDp/hgPa0CH1cusnj40= dependencies: babel-helper-replace-supers "^6.24.1" babel-runtime "^6.22.0" -babel-plugin-transform-es2015-parameters@^6.24.1: +babel-plugin-transform-es2015-parameters@^6.23.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz#57ac351ab49caf14a97cd13b09f66fdf0a625f2b" + integrity sha1-V6w1GrScrxSpfNE7CfZv3wpiXys= dependencies: babel-helper-call-delegate "^6.24.1" babel-helper-get-function-arity "^6.24.1" @@ -698,9 +773,10 @@ babel-plugin-transform-es2015-parameters@^6.24.1: babel-traverse "^6.24.1" babel-types "^6.24.1" -babel-plugin-transform-es2015-shorthand-properties@^6.24.1: +babel-plugin-transform-es2015-shorthand-properties@^6.22.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz#24f875d6721c87661bbd99a4622e51f14de38aa0" + integrity sha1-JPh11nIch2YbvZmkYi5R8U3jiqA= dependencies: babel-runtime "^6.22.0" babel-types "^6.24.1" @@ -711,9 +787,10 @@ babel-plugin-transform-es2015-spread@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-sticky-regex@^6.24.1: +babel-plugin-transform-es2015-sticky-regex@^6.22.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz#00c1cdb1aca71112cdf0cf6126c2ed6b457ccdbc" + integrity sha1-AMHNsaynERLN8M9hJsLta0V8zbw= dependencies: babel-helper-regex "^6.24.1" babel-runtime "^6.22.0" @@ -725,23 +802,35 @@ babel-plugin-transform-es2015-template-literals@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-typeof-symbol@^6.22.0: +babel-plugin-transform-es2015-typeof-symbol@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz#dec09f1cddff94b52ac73d505c84df59dcceb372" + integrity sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I= dependencies: babel-runtime "^6.22.0" -babel-plugin-transform-es2015-unicode-regex@^6.24.1: +babel-plugin-transform-es2015-unicode-regex@^6.22.0: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz#d38b12f42ea7323f729387f18a7c5ae1faeb35e9" + integrity sha1-04sS9C6nMj9yk4fxinxa4frrNek= dependencies: babel-helper-regex "^6.24.1" babel-runtime "^6.22.0" regexpu-core "^2.0.0" -babel-plugin-transform-regenerator@^6.24.1: +babel-plugin-transform-exponentiation-operator@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz#2ab0c9c7f3098fa48907772bb813fe41e8de3a0e" + integrity sha1-KrDJx/MJj6SJB3cruBP+QejeOg4= + dependencies: + babel-helper-builder-binary-assignment-operator-visitor "^6.24.1" + babel-plugin-syntax-exponentiation-operator "^6.8.0" + babel-runtime "^6.22.0" + +babel-plugin-transform-regenerator@^6.22.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz#e0703696fbde27f0a3efcacf8b4dca2f7b3a8f2f" + integrity sha1-4HA2lvveJ/Cj78rPi03KL3s6jy8= dependencies: regenerator-transform "^0.10.0" @@ -760,34 +849,41 @@ babel-polyfill@^6.26.0: core-js "^2.5.0" regenerator-runtime "^0.10.5" -babel-preset-es2015@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz#d44050d6bc2c9feea702aaf38d727a0210538939" +babel-preset-env@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.7.0.tgz#dea79fa4ebeb883cd35dab07e260c1c9c04df77a" + integrity sha512-9OR2afuKDneX2/q2EurSftUYM0xGu4O2D9adAhVfADDhrYDaxXV0rBbevVYoY9n6nyX1PmQW/0jtpJvUNr9CHg== dependencies: babel-plugin-check-es2015-constants "^6.22.0" + babel-plugin-syntax-trailing-function-commas "^6.22.0" + babel-plugin-transform-async-to-generator "^6.22.0" babel-plugin-transform-es2015-arrow-functions "^6.22.0" babel-plugin-transform-es2015-block-scoped-functions "^6.22.0" - babel-plugin-transform-es2015-block-scoping "^6.24.1" - babel-plugin-transform-es2015-classes "^6.24.1" - babel-plugin-transform-es2015-computed-properties "^6.24.1" - babel-plugin-transform-es2015-destructuring "^6.22.0" - babel-plugin-transform-es2015-duplicate-keys "^6.24.1" - babel-plugin-transform-es2015-for-of "^6.22.0" - babel-plugin-transform-es2015-function-name "^6.24.1" + babel-plugin-transform-es2015-block-scoping "^6.23.0" + babel-plugin-transform-es2015-classes "^6.23.0" + babel-plugin-transform-es2015-computed-properties "^6.22.0" + babel-plugin-transform-es2015-destructuring "^6.23.0" + babel-plugin-transform-es2015-duplicate-keys "^6.22.0" + babel-plugin-transform-es2015-for-of "^6.23.0" + babel-plugin-transform-es2015-function-name "^6.22.0" babel-plugin-transform-es2015-literals "^6.22.0" - babel-plugin-transform-es2015-modules-amd "^6.24.1" - babel-plugin-transform-es2015-modules-commonjs "^6.24.1" - babel-plugin-transform-es2015-modules-systemjs "^6.24.1" - babel-plugin-transform-es2015-modules-umd "^6.24.1" - babel-plugin-transform-es2015-object-super "^6.24.1" - babel-plugin-transform-es2015-parameters "^6.24.1" - babel-plugin-transform-es2015-shorthand-properties "^6.24.1" + babel-plugin-transform-es2015-modules-amd "^6.22.0" + babel-plugin-transform-es2015-modules-commonjs "^6.23.0" + babel-plugin-transform-es2015-modules-systemjs "^6.23.0" + babel-plugin-transform-es2015-modules-umd "^6.23.0" + babel-plugin-transform-es2015-object-super "^6.22.0" + babel-plugin-transform-es2015-parameters "^6.23.0" + babel-plugin-transform-es2015-shorthand-properties "^6.22.0" babel-plugin-transform-es2015-spread "^6.22.0" - babel-plugin-transform-es2015-sticky-regex "^6.24.1" + babel-plugin-transform-es2015-sticky-regex "^6.22.0" babel-plugin-transform-es2015-template-literals "^6.22.0" - babel-plugin-transform-es2015-typeof-symbol "^6.22.0" - babel-plugin-transform-es2015-unicode-regex "^6.24.1" - babel-plugin-transform-regenerator "^6.24.1" + babel-plugin-transform-es2015-typeof-symbol "^6.23.0" + babel-plugin-transform-es2015-unicode-regex "^6.22.0" + babel-plugin-transform-exponentiation-operator "^6.22.0" + babel-plugin-transform-regenerator "^6.22.0" + browserslist "^3.2.6" + invariant "^2.2.2" + semver "^5.3.0" babel-register@^6.26.0: version "6.26.0" @@ -968,6 +1064,14 @@ browser-stdout@1.3.1: resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== +browserslist@^3.2.6: + version "3.2.8" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-3.2.8.tgz#b0005361d6471f0f5952797a76fc985f1f978fc6" + integrity sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ== + dependencies: + caniuse-lite "^1.0.30000844" + electron-to-chromium "^1.3.47" + bson-stream@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/bson-stream/-/bson-stream-0.0.8.tgz#5fd9f1df6c34c20005948b6e031a33bb1d11e83f" @@ -1053,6 +1157,11 @@ camelcase@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" +caniuse-lite@^1.0.30000844: + version "1.0.30000918" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000918.tgz#6288f79da3c5c8b45e502f47ad8f3eb91f1379a9" + integrity sha512-CAZ9QXGViBvhHnmIHhsTPSWFBujDaelKnUj7wwImbyQRxmXynYqKGi3UaZTSz9MoVh+1EVxOS/DFIkrJYgR3aw== + caseless@~0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" @@ -1232,6 +1341,11 @@ commander@^2.11.0: version "2.12.2" resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.2.tgz#0f5946c427ed9ec0d91a46bb9def53e54650e555" +commander@~2.17.1: + version "2.17.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" + integrity sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg== + communibase-connector-js@0.5.11: version "0.5.11" resolved "https://registry.yarnpkg.com/communibase-connector-js/-/communibase-connector-js-0.5.11.tgz#1b1ea5b30053adf26a60f69c074f323491544dfb" @@ -1607,6 +1721,11 @@ ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" +electron-to-chromium@^1.3.47: + version "1.3.90" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.90.tgz#b4c51b8303beff18f2b74817402bf4898e09558a" + integrity sha512-IjJZKRhFbWSOX1w0sdIXgp4CMRguu6UYcTckyFF/Gjtemsu/25eZ+RXwFlV+UWcIueHyQA1UnRJxocTpH5NdGA== + encodeurl@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.1.tgz#79e3d58655346909fe6f0f45a5de68103b294d20" @@ -2316,23 +2435,36 @@ grunt@^1.0.1: path-is-absolute "~1.0.0" rimraf "~2.2.8" -handlebars@^2.0.0: +"handlebars-v2@npm:handlebars@2.0.0": version "2.0.0" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-2.0.0.tgz#6e9d7f8514a3467fa5e9f82cc158ecfc1d5ac76f" + integrity sha1-bp1/hRSjRn+l6fgswVjs/B1ax28= dependencies: optimist "~0.3" optionalDependencies: uglify-js "~2.3" -handlebars@^3.0.1: +"handlebars-v3@npm:handlebars@3.0.3", handlebars@^3.0.1: version "3.0.3" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-3.0.3.tgz#0e09651a2f0fb3c949160583710d551f92e6d2ad" + integrity sha1-DgllGi8Ps8lJFgWDcQ1VH5Lm0q0= dependencies: optimist "^0.6.1" source-map "^0.1.40" optionalDependencies: uglify-js "~2.3" +"handlebars-v4@npm:handlebars@4.0.12", handlebars@>=2.0.0: + version "4.0.12" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.12.tgz#2c15c8a96d46da5e266700518ba8cb8d919d5bc5" + integrity sha512-RhmTekP+FZL+XNhwS1Wf+bTTZpdLougwt5pcgA1tuz6Jcx0fpH/7z0qd71RKnZHBCxIRBHfBOnio4gViPemNzA== + dependencies: + async "^2.5.0" + optimist "^0.6.1" + source-map "^0.6.1" + optionalDependencies: + uglify-js "^3.1.4" + handlebars@^4.0.6: version "4.0.11" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc" @@ -4295,6 +4427,11 @@ source-map@^0.5.0, source-map@^0.5.6, source-map@~0.5.1: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" +source-map@^0.6.1, source-map@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + spdx-correct@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" @@ -4587,6 +4724,14 @@ uglify-js@^2.6: optionalDependencies: uglify-to-browserify "~1.0.0" +uglify-js@^3.1.4: + version "3.4.9" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3" + integrity sha512-8CJsbKOtEbnJsTyv6LE6m6ZKniqMiFWmm9sRbopbkGs3gMPPfd3Fh8iIA4Ykv5MgaTbqHr4BaoGLJLZNhsrW1Q== + dependencies: + commander "~2.17.1" + source-map "~0.6.1" + uglify-js@~2.3: version "2.3.6" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.3.6.tgz#fa0984770b428b7a9b2a8058f46355d14fef211a" From b5d4a711693fb9783c5821d509ea04b4dc18aeb1 Mon Sep 17 00:00:00 2001 From: Aubrey Hewes Date: Tue, 11 Dec 2018 22:28:28 +0100 Subject: [PATCH 2/4] https://bit.ly/oh-so-pretty --- src/inc/HandlebarsAST.js | 60 ++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/src/inc/HandlebarsAST.js b/src/inc/HandlebarsAST.js index d9230cb..a3f483a 100644 --- a/src/inc/HandlebarsAST.js +++ b/src/inc/HandlebarsAST.js @@ -10,12 +10,14 @@ const isHelper = function(node) { // in v4 this information is not available in the AST so we need to // check this our self... To do this we use the following code taken from // https://github.com/wycats/handlebars.js/blob/95d84badcae89aa72a6f1433b851304700320920/lib/handlebars/compiler/ast.js - return (node.type === 'SubExpression') - || ((node.type === 'MustacheStatement' || node.type === 'BlockStatement') - && !!((node.params && node.params.length) || node.hash)); + return ( + node.type === "SubExpression" || + ((node.type === "MustacheStatement" || node.type === "BlockStatement") && + !!((node.params && node.params.length) || node.hash)) + ); }; -module.exports.getV2Paths = (node) => { +module.exports.getV2Paths = node => { let result = []; if (!node || !node.type) { @@ -111,7 +113,7 @@ module.exports.getV2Paths = (node) => { return result; }; -module.exports.getV4Paths = (node) => { +module.exports.getV4Paths = node => { let result = []; if (!node || !node.type) { return result; @@ -125,7 +127,7 @@ module.exports.getV4Paths = (node) => { }); }); break; - case 'BlockStatement': + case "BlockStatement": // const blockKeys = node.params.map(param => this.getV4Paths(param)); blockKeys = []; node.params.forEach(param => { @@ -134,34 +136,38 @@ module.exports.getV4Paths = (node) => { }); }); - if ((!isHelper(node) || (node.path && node.path.original === 'each')) && node.program) { + if ( + (!isHelper(node) || (node.path && node.path.original === "each")) && + node.program + ) { this.getV4Paths(node.program).forEach(subValue => { result.push(`${blockKeys[0]}.#.${subValue}`); }); break; } - if (node.path && node.path.original === 'filter') { + if (node.path && node.path.original === "filter") { var d = true; // look for used properties in equation - [ - node.params[1], - node.params[node.params.length === 4 ? 3 : 2] - ].forEach(possiblePropertyNode => { - switch (possiblePropertyNode.type) { - case "StringLiteral": - // e.g. ../session.personId - result.push(`${blockKeys[0]}.#.${possiblePropertyNode.original}`); - break; - - // @ TODO BooleanLiteral ? - // @ TODO the following - case "ID": - // e.g. personId - result.push(possiblePropertyNode.original); - break; + [node.params[1], node.params[node.params.length === 4 ? 3 : 2]].forEach( + possiblePropertyNode => { + switch (possiblePropertyNode.type) { + case "StringLiteral": + // e.g. ../session.personId + result.push( + `${blockKeys[0]}.#.${possiblePropertyNode.original}` + ); + break; + + // @ TODO BooleanLiteral ? + // @ TODO the following + case "ID": + // e.g. personId + result.push(possiblePropertyNode.original); + break; + } } - }); + ); if (node.program) { this.getV4Paths(node.program).forEach(subValue => { @@ -192,7 +198,7 @@ module.exports.getV4Paths = (node) => { } break; - case 'MustacheStatement': + case "MustacheStatement": if (!isHelper(node)) { result.push(node.path.original); } @@ -224,7 +230,7 @@ module.exports.getV4Paths = (node) => { * * @returns {Array} result - The requested paths */ -module.exports.getTemplatePaths = (node) => { +module.exports.getTemplatePaths = node => { if (debug) { // eslint-disable-next-line no-console console.log(`${JSON.stringify(node)}\n\n`); From 01dbafed3e02eb53a6b45b91ab2471cfe4d63fd2 Mon Sep 17 00:00:00 2001 From: Aubrey Hewes Date: Tue, 11 Dec 2018 22:29:37 +0100 Subject: [PATCH 3/4] fixed superfluous dev support --- src/inc/HandlebarsAST.js | 2 +- src/index.js | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/inc/HandlebarsAST.js b/src/inc/HandlebarsAST.js index a3f483a..5014641 100644 --- a/src/inc/HandlebarsAST.js +++ b/src/inc/HandlebarsAST.js @@ -147,7 +147,6 @@ module.exports.getV4Paths = node => { } if (node.path && node.path.original === "filter") { - var d = true; // look for used properties in equation [node.params[1], node.params[node.params.length === 4 ? 3 : 2]].forEach( possiblePropertyNode => { @@ -249,6 +248,7 @@ module.exports.getTemplatePaths = node => { } if (debug) { + // eslint-disable-next-line no-console console.log(uniq(paths)); } return uniq(paths); diff --git a/src/index.js b/src/index.js index 22a5702..eb4f3b8 100755 --- a/src/index.js +++ b/src/index.js @@ -246,8 +246,4 @@ module.exports = function exports(config) { this.setSerializers = serializers => { Object.assign(entitySerializers, serializers); }; - - this.setDebug = function setDebug(enable) { - debug = enable; - }; }; From 84c8686a95b1c670a354f711cd2bdc8c5226925f Mon Sep 17 00:00:00 2001 From: Aubrey Hewes Date: Tue, 11 Dec 2018 22:34:16 +0100 Subject: [PATCH 4/4] better docs --- src/inc/HandlebarsAST.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inc/HandlebarsAST.js b/src/inc/HandlebarsAST.js index 5014641..8518c37 100644 --- a/src/inc/HandlebarsAST.js +++ b/src/inc/HandlebarsAST.js @@ -9,7 +9,7 @@ const isHelper = function(node) { } // in v4 this information is not available in the AST so we need to // check this our self... To do this we use the following code taken from - // https://github.com/wycats/handlebars.js/blob/95d84badcae89aa72a6f1433b851304700320920/lib/handlebars/compiler/ast.js + // https://github.com/wycats/handlebars.js/blob/95d84badcae89aa72a6f1433b851304700320920/lib/handlebars/compiler/ast.js#L8 return ( node.type === "SubExpression" || ((node.type === "MustacheStatement" || node.type === "BlockStatement") &&