diff --git a/src/index.js b/src/index.js index 236077a..e1d4efd 100644 --- a/src/index.js +++ b/src/index.js @@ -47,12 +47,13 @@ function handleExtendsNodes(tree, options, messages) { locals = JSON.parse(extendsNode.attrs.locals); } catch {} } - options.expressions.locals = merge(options.expressions.locals, locals); - options.plugins.push(expressions(options.expressions)); + + var options_expressions = merge(options.expressions, {locals}); + var plugins = [...options.plugins, expressions(options_expressions)]; const layoutPath = path.resolve(options.root, extendsNode.attrs.src); const layoutHtml = fs.readFileSync(layoutPath, options.encoding); - const layoutTree = handleExtendsNodes(applyPluginsToTree(parseToPostHtml(layoutHtml), options.plugins), options, messages); + const layoutTree = handleExtendsNodes(applyPluginsToTree(parseToPostHtml(layoutHtml), plugins), options, messages); extendsNode.tag = false; extendsNode.content = mergeExtendsAndLayout(layoutTree, extendsNode, options.strict, options.slotTagName, options.fillTagName); diff --git a/test/extend.js b/test/extend.js index 4f2ed66..550bce0 100644 --- a/test/extend.js +++ b/test/extend.js @@ -154,6 +154,42 @@ describe('Extend', () => { }); }); + it('should accept locals in inherited layout', () => { + mfs.writeFileSync('./parent.html', ` +