Skip to content

Commit b635439

Browse files
committed
feat: multi includes, close #18
1 parent afb0228 commit b635439

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

index.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,22 @@ module.exports = function(options) {
99

1010
return function posthtmlInclude(tree) {
1111
tree.match({ tag: 'include' }, function(node) {
12-
var src = node.attrs.src || false,
13-
content;
12+
var src = node.attrs.src || false;
13+
var content;
14+
var subtree;
15+
var source;
16+
1417
if (src) {
1518
src = path.resolve(options.root, src);
16-
content = parser(fs.readFileSync(src, options.encoding));
19+
source = fs.readFileSync(src, options.encoding);
20+
subtree = parser(source);
21+
subtree.match = tree.match;
22+
content = source.indexOf('include') !== -1? posthtmlInclude(subtree): subtree;
1723

18-
if (typeof options.addDependencyTo === 'object' &&
19-
typeof options.addDependencyTo.addDependency === 'function') {
24+
if (
25+
typeof options.addDependencyTo === 'object' &&
26+
typeof options.addDependencyTo.addDependency === 'function'
27+
) {
2028
console.warn([
2129
"addDependencyTo is deprecated in favor of",
2230
"result.messages.dependency; posthtml-loader >= v1.0.1 will",

0 commit comments

Comments
 (0)