@@ -32,8 +32,8 @@ export function stripComment(comment) {
32
32
. replace ( / - ? - ? ~ ? \} \} $ / , '' ) ;
33
33
}
34
34
35
- export function preparePath ( data , parts , locInfo ) {
36
- locInfo = this . locInfo ( locInfo ) ;
35
+ export function preparePath ( data , parts , loc ) {
36
+ loc = this . locInfo ( loc ) ;
37
37
38
38
let original = data ? '@' : '' ,
39
39
dig = [ ] ,
@@ -49,7 +49,7 @@ export function preparePath(data, parts, locInfo) {
49
49
50
50
if ( ! isLiteral && ( part === '..' || part === '.' || part === 'this' ) ) {
51
51
if ( dig . length > 0 ) {
52
- throw new Exception ( 'Invalid path: ' + original , { loc : locInfo } ) ;
52
+ throw new Exception ( 'Invalid path: ' + original , { loc} ) ;
53
53
} else if ( part === '..' ) {
54
54
depth ++ ;
55
55
depthString += '../' ;
@@ -59,15 +59,30 @@ export function preparePath(data, parts, locInfo) {
59
59
}
60
60
}
61
61
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
+ } ;
63
70
}
64
71
65
72
export function prepareMustache ( path , params , hash , open , strip , locInfo ) {
66
73
// Must use charAt to support IE pre-10
67
74
let escapeFlag = open . charAt ( 3 ) || open . charAt ( 2 ) ,
68
75
escaped = escapeFlag !== '{' && escapeFlag !== '&' ;
69
76
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
+ } ;
71
86
}
72
87
73
88
export function prepareRawBlock ( openRawBlock , contents , close , locInfo ) {
@@ -78,13 +93,24 @@ export function prepareRawBlock(openRawBlock, contents, close, locInfo) {
78
93
}
79
94
80
95
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
+ } ;
82
102
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
+ } ;
88
114
}
89
115
90
116
export function prepareBlock ( openBlock , program , inverseAndProgram , close , inverted , locInfo ) {
@@ -115,11 +141,18 @@ export function prepareBlock(openBlock, program, inverseAndProgram, close, inver
115
141
program = inverted ;
116
142
}
117
143
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
+ } ;
123
156
}
124
157
125
158
export function prepareProgram ( statements , loc ) {
@@ -143,7 +176,12 @@ export function prepareProgram(statements, loc) {
143
176
}
144
177
}
145
178
146
- return new this . Program ( statements , null , { } , loc ) ;
179
+ return {
180
+ type : 'Program' ,
181
+ body : statements ,
182
+ strip : { } ,
183
+ loc : loc
184
+ } ;
147
185
}
148
186
149
187
0 commit comments