1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
function Visitor() {}
Visitor.prototype = {
constructor: Visitor,
accept: function(object) {
return object && this[object.type](object);
},
Program: function(program) {
var body = program.body,
i, l;
for(i=0, l=body.length; i<l; i++) {
this.accept(body[i]);
}
},
MustacheStatement: function(mustache) {
this.accept(mustache.sexpr);
},
BlockStatement: function(block) {
this.accept(block.sexpr);
this.accept(block.program);
this.accept(block.inverse);
},
PartialStatement: function(partial) {
this.accept(partial.partialName);
this.accept(partial.context);
this.accept(partial.hash);
},
ContentStatement: function(content) {},
CommentStatement: function(comment) {},
SubExpression: function(sexpr) {
var params = sexpr.params, paramStrings = [], hash;
this.accept(sexpr.path);
for(var i=0, l=params.length; i<l; i++) {
this.accept(params[i]);
}
this.accept(sexpr.hash);
},
PathExpression: function(path) {},
StringLiteral: function(string) {},
NumberLiteral: function(number) {},
BooleanLiteral: function(bool) {},
Hash: function(hash) {
var pairs = hash.pairs;
for(var i=0, l=pairs.length; i<l; i++) {
this.accept(pairs[i]);
}
},
HashPair: function(pair) {
this.accept(pair.value);
}
};
export default Visitor;
|