Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = (options = {}) => {
const localsJson = JSON.parse(localsRaw);
posthtmlExpressionsOptions = {
...posthtmlExpressionsOptions,
locals: posthtmlExpressionsOptions.locals ? Object.assign(localsJson, posthtmlExpressionsOptions.locals) : localsJson
locals: posthtmlExpressionsOptions.locals ? Object.assign(posthtmlExpressionsOptions.locals, localsJson) : localsJson
};
} catch {}

Expand Down
3 changes: 3 additions & 0 deletions test/expected/override-global-variables.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>Should override global locals</div>
<div>local</div>
<div>local</div>
3 changes: 3 additions & 0 deletions test/fixtures/override-global-variables.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>Should override global locals</div>
<div>local</div>
<div>local</div>
7 changes: 7 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ test('Should merge global locals', t => {
}})
})

test('Should override global locals', t => {
return process(t, 'override-global-variables', {
posthtmlExpressionsOptions: {
locals: {globalVariable: 'global'}
}})
})

test('Should merge global variables and evaluate each local variable', t => {
return process(t, 'multiple-include', {
posthtmlExpressionsOptions: {
Expand Down