@@ -32,8 +32,8 @@ export function stripComment(comment) {
3232 . replace ( / - ? - ? ~ ? \} \} $ / , '' ) ;
3333}
3434
35- export function preparePath ( data , parts , locInfo ) {
36- locInfo = this . locInfo ( locInfo ) ;
35+ export function preparePath ( data , parts , loc ) {
36+ loc = this . locInfo ( loc ) ;
3737
3838 let original = data ? '@' : '' ,
3939 dig = [ ] ,
@@ -49,7 +49,7 @@ export function preparePath(data, parts, locInfo) {
4949
5050 if ( ! isLiteral && ( part === '..' || part === '.' || part === 'this' ) ) {
5151 if ( dig . length > 0 ) {
52- throw new Exception ( 'Invalid path: ' + original , { loc : locInfo } ) ;
52+ throw new Exception ( 'Invalid path: ' + original , { loc} ) ;
5353 } else if ( part === '..' ) {
5454 depth ++ ;
5555 depthString += '../' ;
@@ -59,15 +59,30 @@ export function preparePath(data, parts, locInfo) {
5959 }
6060 }
6161
62- return new this . PathExpression ( data , depth , dig , original , locInfo ) ;
62+ return {
63+ type : 'PathExpression' ,
64+ data,
65+ depth,
66+ parts : dig ,
67+ original,
68+ loc
69+ } ;
6370}
6471
6572export function prepareMustache ( path , params , hash , open , strip , locInfo ) {
6673 // Must use charAt to support IE pre-10
6774 let escapeFlag = open . charAt ( 3 ) || open . charAt ( 2 ) ,
6875 escaped = escapeFlag !== '{' && escapeFlag !== '&' ;
6976
70- return new this . MustacheStatement ( path , params , hash , escaped , strip , this . locInfo ( locInfo ) ) ;
77+ return {
78+ type : 'MustacheStatement' ,
79+ path,
80+ params,
81+ hash,
82+ escaped,
83+ strip,
84+ loc : this . locInfo ( locInfo )
85+ } ;
7186}
7287
7388export function prepareRawBlock ( openRawBlock , contents , close , locInfo ) {
@@ -78,13 +93,24 @@ export function prepareRawBlock(openRawBlock, contents, close, locInfo) {
7893 }
7994
8095 locInfo = this . locInfo ( locInfo ) ;
81- let program = new this . Program ( contents , null , { } , locInfo ) ;
96+ let program = {
97+ type : 'Program' ,
98+ body : contents ,
99+ strip : { } ,
100+ loc : locInfo
101+ } ;
82102
83- return new this . BlockStatement (
84- openRawBlock . path , openRawBlock . params , openRawBlock . hash ,
85- program , undefined ,
86- { } , { } , { } ,
87- locInfo ) ;
103+ return {
104+ type : 'BlockStatement' ,
105+ path : openRawBlock . path ,
106+ params : openRawBlock . params ,
107+ hash : openRawBlock . hash ,
108+ program,
109+ openStrip : { } ,
110+ inverseStrip : { } ,
111+ closeStrip : { } ,
112+ loc : locInfo
113+ } ;
88114}
89115
90116export function prepareBlock ( openBlock , program , inverseAndProgram , close , inverted , locInfo ) {
@@ -115,11 +141,18 @@ export function prepareBlock(openBlock, program, inverseAndProgram, close, inver
115141 program = inverted ;
116142 }
117143
118- return new this . BlockStatement (
119- openBlock . path , openBlock . params , openBlock . hash ,
120- program , inverse ,
121- openBlock . strip , inverseStrip , close && close . strip ,
122- this . locInfo ( locInfo ) ) ;
144+ return {
145+ type : 'BlockStatement' ,
146+ path : openBlock . path ,
147+ params : openBlock . params ,
148+ hash : openBlock . hash ,
149+ program,
150+ inverse,
151+ openStrip : openBlock . strip ,
152+ inverseStrip,
153+ closeStrip : close && close . strip ,
154+ loc : this . locInfo ( locInfo )
155+ } ;
123156}
124157
125158export function prepareProgram ( statements , loc ) {
@@ -143,7 +176,12 @@ export function prepareProgram(statements, loc) {
143176 }
144177 }
145178
146- return new this . Program ( statements , null , { } , loc ) ;
179+ return {
180+ type : 'Program' ,
181+ body : statements ,
182+ strip : { } ,
183+ loc : loc
184+ } ;
147185}
148186
149187
0 commit comments