Skip to content

Commit bc63258

Browse files
authored
Merge pull request #42 from posthtml/milestone-1.4.2
Milestone 1.4.2
2 parents 8aa7c28 + 2124c3f commit bc63258

6 files changed

Lines changed: 83 additions & 70 deletions

File tree

lib/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ module.exports = (options = {}) => {
2525
if (src) {
2626
src = path.resolve(options.root, src);
2727
source = fs.readFileSync(src, options.encoding);
28-
29-
if (locals) {
28+
if (locals && locals.includes(':')) {
3029
locals = JSON.parse(locals);
3130
const result = posthtml()
3231
.use(expressions({locals}))

package-lock.json

Lines changed: 73 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "posthtml-include",
3-
"version": "1.4.1",
3+
"version": "1.4.2",
44
"description": "Include files in HTML",
55
"license": "MIT",
66
"author": "Ivan Voischev <voischev.ivan@ya.ru>",
@@ -30,13 +30,13 @@
3030
],
3131
"dependencies": {
3232
"posthtml": "^0.12.0",
33-
"posthtml-expressions": "^1.3.0",
33+
"posthtml-expressions": "^1.3.2",
3434
"posthtml-parser": "^0.4.2"
3535
},
3636
"devDependencies": {
3737
"ava": "^3.6.0",
3838
"np": "^6.2.0",
3939
"nyc": "^15.0.1",
40-
"xo": "^0.28.3"
40+
"xo": "^0.29.0"
4141
}
4242
}

test/expected/locals-not-json.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>index</h1><h2>{{ text }}</h2>

test/fixtures/locals-not-json.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>index</h1><include src="./test/fixtures/includes/3.html" locals='{{ response }}'></include>

test/test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ test('Locals', t => {
3333
return process(t, 'locals')
3434
})
3535

36+
test('Locals not json', t => {
37+
return process(t, 'locals-not-json')
38+
})
39+
3640
test('addDependency message', t => {
3741
const includePath = require('path').resolve('./test/fixtures/blocks/button/button.html')
3842

0 commit comments

Comments
 (0)