From 6b084a245f84cac38a8630a5eae4a13d24e2cc81 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 May 2021 16:58:57 +0000 Subject: [PATCH 1/7] build(deps): bump lodash from 4.17.20 to 4.17.21 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.20...4.17.21) Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 38823c2..42df1fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4208,9 +4208,9 @@ } }, "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, "lodash.flattendeep": { From 68c3122f56fd85e12580b01e4d4d89ee8131f2d6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 May 2021 15:29:49 +0000 Subject: [PATCH 2/7] build(deps): bump hosted-git-info from 2.8.8 to 2.8.9 Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9. - [Release notes](https://github.com/npm/hosted-git-info/releases) - [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md) - [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9) Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 38823c2..881bc67 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3428,9 +3428,9 @@ } }, "hosted-git-info": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", - "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", "dev": true }, "html-escaper": { From 3af10603941886ad0b7382db94dc9af3cefc3046 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Jun 2021 19:37:04 +0000 Subject: [PATCH 3/7] build(deps): bump trim-newlines from 3.0.0 to 3.0.1 Bumps [trim-newlines](https://github.com/sindresorhus/trim-newlines) from 3.0.0 to 3.0.1. - [Release notes](https://github.com/sindresorhus/trim-newlines/releases) - [Commits](https://github.com/sindresorhus/trim-newlines/commits) --- updated-dependencies: - dependency-name: trim-newlines dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f071aa7..e61db2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6626,9 +6626,9 @@ } }, "trim-newlines": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.0.tgz", - "integrity": "sha512-C4+gOpvmxaSMKuEf9Qc134F1ZuOHVXKRbtEflf4NTtuuJDEIJ9p5PXsalL8SkeRw+qit1Mo+yuvMPAKwWg/1hA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz", + "integrity": "sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==", "dev": true }, "trim-off-newlines": { From e391cb06ef55e120f84e71345073c0b748e69f94 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Jun 2021 07:23:58 +0000 Subject: [PATCH 4/7] build(deps): bump normalize-url from 4.5.0 to 4.5.1 Bumps [normalize-url](https://github.com/sindresorhus/normalize-url) from 4.5.0 to 4.5.1. - [Release notes](https://github.com/sindresorhus/normalize-url/releases) - [Commits](https://github.com/sindresorhus/normalize-url/commits) --- updated-dependencies: - dependency-name: normalize-url dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e61db2e..6d26da7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4688,9 +4688,9 @@ "dev": true }, "normalize-url": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz", - "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==", + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.1.tgz", + "integrity": "sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==", "dev": true }, "npm-run-path": { From 1939c734a71420dadd30e9c66efd72c8e2a8d513 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Aug 2021 06:09:43 +0000 Subject: [PATCH 5/7] build(deps): bump path-parse from 1.0.6 to 1.0.7 Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6d26da7..f06f338 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5156,9 +5156,9 @@ "dev": true }, "path-parse": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "path-type": { From 8ce8ddef0d3c9b3cfc01d2c8e4d29574822617c5 Mon Sep 17 00:00:00 2001 From: Andrey Polyakov Date: Sat, 2 Oct 2021 17:28:44 +0300 Subject: [PATCH 6/7] Allow to merge locals with posthtml-expressions config locals --- lib/index.js | 4 ++-- test/expected/global-variables.html | 3 +++ test/fixtures/global-variables.html | 6 ++++++ test/fixtures/includes/6.html | 2 ++ test/test.js | 7 +++++++ 5 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 test/expected/global-variables.html create mode 100644 test/fixtures/global-variables.html create mode 100644 test/fixtures/includes/6.html diff --git a/lib/index.js b/lib/index.js index 8e444e7..3e6602e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -21,7 +21,6 @@ module.exports = (options = {}) => { let subtree; let source; const posthtmlExpressionsOptions = options.posthtmlExpressionsOptions || {locals: false}; - if (options.delimiters) { posthtmlExpressionsOptions.delimiters = options.delimiters; } @@ -32,7 +31,8 @@ module.exports = (options = {}) => { try { const localsRaw = node.attrs.locals || (node.content ? node.content.join().replace(/\n/g, '') : false); - posthtmlExpressionsOptions.locals = JSON.parse(localsRaw); + const localsJson = JSON.parse(localsRaw); + posthtmlExpressionsOptions.locals = posthtmlExpressionsOptions.locals ? Object.assign(localsJson, posthtmlExpressionsOptions.locals) : localsJson; } catch {} if (posthtmlExpressionsOptions.locals) { diff --git a/test/expected/global-variables.html b/test/expected/global-variables.html new file mode 100644 index 0000000..de6c93d --- /dev/null +++ b/test/expected/global-variables.html @@ -0,0 +1,3 @@ +
Should merge global locals
+
local
+
global
diff --git a/test/fixtures/global-variables.html b/test/fixtures/global-variables.html new file mode 100644 index 0000000..fbd9701 --- /dev/null +++ b/test/fixtures/global-variables.html @@ -0,0 +1,6 @@ +
Should merge global locals
+ + { + "localVariable": "local" + } + diff --git a/test/fixtures/includes/6.html b/test/fixtures/includes/6.html new file mode 100644 index 0000000..35e0cf1 --- /dev/null +++ b/test/fixtures/includes/6.html @@ -0,0 +1,2 @@ +
{{ localVariable }}
+
{{ globalVariable }}
diff --git a/test/test.js b/test/test.js index acf8eea..d9d85b2 100644 --- a/test/test.js +++ b/test/test.js @@ -53,6 +53,13 @@ test('Shoult not cut children elements', t => { return process(t, 'not-clear-rest') }) +test('Should merge global locals', t => { + return process(t, 'global-variables', { + posthtmlExpressionsOptions: { + locals: {globalVariable: 'global'} + }}) +}) + test('addDependency message', t => { const includePath = require('path').resolve('./test/fixtures/blocks/button/button.html') From 592eee426da3d0c95ced39bcbb45a3babe809b0e Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Mon, 4 Oct 2021 09:28:08 +0300 Subject: [PATCH 7/7] 1.7.2 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index f06f338..4c300e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "posthtml-include", - "version": "1.7.1", + "version": "1.7.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 4b003b4..f8ada5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "posthtml-include", - "version": "1.7.1", + "version": "1.7.2", "description": "Include files in HTML", "license": "MIT", "author": "Ivan Voischev ",