pug-linker
Advanced tools
Comparing version 2.0.3 to 3.0.0
24
index.js
@@ -16,6 +16,6 @@ 'use strict'; | ||
var hasExtends = ast.nodes[0].type === 'Extends'; | ||
checkExtendPosition(ast, hasExtends); | ||
if (hasExtends) { | ||
extendsNode = ast.nodes.shift(); | ||
} | ||
checkExtendPosition(ast, hasExtends); | ||
} | ||
@@ -59,2 +59,3 @@ ast = applyIncludes(ast); | ||
parent.nodes = mixins.concat(parent.nodes); | ||
parent.hasExtends = true; | ||
return parent; | ||
@@ -81,5 +82,4 @@ } | ||
flattenParentBlocks(parentBlock.parents, accumulator); | ||
} else { | ||
accumulator.push(parentBlock); | ||
} | ||
accumulator.push(parentBlock); | ||
}); | ||
@@ -129,6 +129,20 @@ return accumulator; | ||
if (node.type === 'Include') { | ||
replace(applyYield(link(node.file.ast), node.block)); | ||
var childAST = link(node.file.ast); | ||
if (childAST.hasExtends) { | ||
childAST = removeBlocks(childAST); | ||
} | ||
replace(applyYield(childAST, node.block)); | ||
} | ||
}); | ||
} | ||
function removeBlocks(ast) { | ||
return walk(ast, function (node, replace) { | ||
if (node.type === 'NamedBlock') { | ||
replace({ | ||
type: 'Block', | ||
nodes: node.nodes | ||
}); | ||
} | ||
}); | ||
} | ||
@@ -171,3 +185,3 @@ function applyYield(ast, block) { | ||
} else { | ||
error('EXTENDS_NOT_FIRST', 'Declaration of template inheritance ("extends") should be the first thing in the file.', node); | ||
error('EXTENDS_NOT_FIRST', 'Declaration of template inheritance ("extends") should be the first thing in the file. There can only be one extends statement per file.', node); | ||
} | ||
@@ -174,0 +188,0 @@ } |
{ | ||
"name": "pug-linker", | ||
"version": "2.0.3", | ||
"version": "3.0.0", | ||
"description": "Link multiple pug ASTs together using include/extends", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3983
270582