@@ -16,10 +16,12 @@ export default (options = {}) => {
16
16
options . root = options . root || './' ;
17
17
options . plugins = options . plugins || [ ] ;
18
18
options . strict = Object . prototype . hasOwnProperty . call ( options , 'strict' ) ? ! ! options . strict : true ;
19
+ options . slotTagName = options . slotTagName || 'block' ;
20
+ options . fillTagName = options . fillTagName || 'block' ;
19
21
20
22
tree = handleExtendsNodes ( tree , options , tree . messages ) ;
21
23
22
- const blockNodes = getBlockNodes ( tree ) ;
24
+ const blockNodes = getBlockNodes ( tree , options . slotTagName ) ;
23
25
for ( let blockName of Object . keys ( blockNodes ) ) {
24
26
let blockNode = blockNodes [ blockName ] ;
25
27
blockNode . tag = false ;
@@ -42,7 +44,7 @@ function handleExtendsNodes(tree, options, messages) {
42
44
let layoutTree = handleExtendsNodes ( applyPluginsToTree ( parseToPostHtml ( layoutHtml ) , options . plugins ) , options , messages ) ;
43
45
44
46
extendsNode . tag = false ;
45
- extendsNode . content = mergeExtendsAndLayout ( layoutTree , extendsNode , options . strict ) ;
47
+ extendsNode . content = mergeExtendsAndLayout ( layoutTree , extendsNode , options . strict , options . slotTagName , options . fillTagName ) ;
46
48
messages . push ( {
47
49
type : 'dependency' ,
48
50
file : layoutPath ,
@@ -60,13 +62,13 @@ function applyPluginsToTree(tree, plugins) {
60
62
}
61
63
62
64
63
- function mergeExtendsAndLayout ( layoutTree , extendsNode , strictNames ) {
64
- const layoutBlockNodes = getBlockNodes ( layoutTree ) ;
65
- const extendsBlockNodes = getBlockNodes ( extendsNode . content ) ;
65
+ function mergeExtendsAndLayout ( layoutTree , extendsNode , strictNames , slotTagName , fillTagName ) {
66
+ const layoutBlockNodes = getBlockNodes ( layoutTree , slotTagName ) ;
67
+ const extendsBlockNodes = getBlockNodes ( extendsNode . content , fillTagName ) ;
66
68
67
69
for ( let layoutBlockName of Object . keys ( layoutBlockNodes ) ) {
68
70
let extendsBlockNode = extendsBlockNodes [ layoutBlockName ] ;
69
- if ( ! extendsBlockNode ) {
71
+ if ( ! extendsBlockNode ) {
70
72
continue ;
71
73
}
72
74
@@ -123,10 +125,10 @@ function getBlockType(blockNode) {
123
125
}
124
126
125
127
126
- function getBlockNodes ( content = [ ] ) {
128
+ function getBlockNodes ( content = [ ] , tag ) {
127
129
let blockNodes = { } ;
128
130
129
- match . call ( content , { tag : 'block' } , node => {
131
+ match . call ( content , { tag} , node => {
130
132
if ( ! node . attrs || ! node . attrs . name ) {
131
133
throw getError ( errors . BLOCK_NO_NAME ) ;
132
134
}
0 commit comments