@@ -73,39 +73,39 @@ class Layout {
7373
7474 utils . getFileTime ( filename , ( time ) => {
7575 this . templateTimes [ filename ] = time ;
76-
76+
7777 const extendsName = this . getExtends ( content ) ;
78-
78+
7979 // 判断是否第一行是否有 extends 指令
8080 if ( extendsName ) {
8181 // 有 extends 指令,表示需要解析父模板
8282 this . parseParent ( extendsName , content , filename ) ;
8383 // 处理模板
8484 content = this . processParent ( content ) ;
8585 }
86-
86+
8787 content = this . removeCommand ( content ) ;
88-
88+
8989 // 准备缓存文件的数据
90-
90+
9191 const cacheInfo = {
9292 version : this . core . version ,
9393 files : this . templateTimes
9494 } ;
95-
95+
9696 let result = `'/* changba template engine\n${ JSON . stringify ( cacheInfo ) } \n*/+'` ;
97-
97+
9898 if ( block !== '' ) {
9999 // 支持直接获取 block 内容
100100 result += this . blocks [ block ] ? this . blocks [ block ] : `Block ${ block } not found!` ;
101101 }
102102 else {
103103 result += this . core . _parse ( content ) ;
104104 }
105-
105+
106106 // 写入缓存(异步)
107107 this . writeCache ( cacheFilename , result ) ;
108-
108+
109109 callback ( null , result ) ;
110110 } ) ;
111111 } ) ;
@@ -144,23 +144,23 @@ class Layout {
144144
145145 utils . getFileTime ( filename , ( time ) => {
146146 this . templateTimes [ filename ] = time ;
147-
147+
148148 // 模板内容入栈,等待后续处理
149149 this . templates . push ( content ) ;
150-
150+
151151 // 获取父模板名称
152152 const extendsName = this . getExtends ( content ) ;
153-
153+
154154 if ( extendsName ) {
155155 // 有 extends 指令,表示需要加载父模板
156156 this . parseParent ( extendsName , content , filename ) ;
157157 }
158-
158+
159159 // 合并每一级的 block 信息,备用
160160 this . rawBlocks . push ( this . getBlocks ( content ) ) ;
161-
161+
162162 this . depth -- ;
163-
163+
164164 if ( this . depth === 0 ) {
165165 // 如果解析到最末一级,则合并最末一级模板的 block 内容
166166 // 此处需要特殊处理,否则会丢掉最末一级模板的 block 内容
0 commit comments