feat(change_detection): change binding syntax to explicitly specify pipes

This commit is contained in:
vsavkin
2015-02-19 17:47:25 -08:00
parent 69e02ee76f
commit 58ba700b14
20 changed files with 236 additions and 101 deletions

View File

@ -33,22 +33,6 @@ export class EmptyExpr extends AST {
}
}
export class Structural extends AST {
value:AST;
constructor(value:AST) {
super();
this.value = value;
}
eval(context) {
return value.eval(context);
}
visit(visitor) {
return visitor.visitStructural(this);
}
}
export class ImplicitReceiver extends AST {
eval(context) {
return context;
@ -204,6 +188,20 @@ export class Formatter extends AST {
}
}
export class Pipe extends AST {
exp:AST;
name:string;
constructor(exp:AST, name:string) {
super();
this.exp = exp;
this.name = name;
}
visit(visitor) {
return visitor.visitPipe(this);
}
}
export class LiteralPrimitive extends AST {
value;
constructor(value) {
@ -460,9 +458,9 @@ export class AstVisitor {
visitAssignment(ast:Assignment) {}
visitBinary(ast:Binary) {}
visitChain(ast:Chain){}
visitStructural(ast:Structural) {}
visitConditional(ast:Conditional) {}
visitFormatter(ast:Formatter) {}
visitPipe(ast:Pipe) {}
visitFunctionCall(ast:FunctionCall) {}
visitImplicitReceiver(ast:ImplicitReceiver) {}
visitKeyedAccess(ast:KeyedAccess) {}

View File

@ -14,6 +14,7 @@ import {
PrefixNot,
Conditional,
Formatter,
Pipe,
Assignment,
Chain,
KeyedAccess,
@ -52,6 +53,15 @@ export class Parser {
return new ASTWithSource(ast, input, location);
}
addPipes(bindingAst:ASTWithSource, pipes:List<String>):ASTWithSource {
if (ListWrapper.isEmpty(pipes)) return bindingAst;
var res = ListWrapper.reduce(pipes,
(result, currentPipeName) => new Pipe(result, currentPipeName),
bindingAst.ast);
return new ASTWithSource(res, bindingAst.source, bindingAst.location);
}
parseTemplateBindings(input:string, location:any):List<TemplateBinding> {
var tokens = this._lexer.tokenize(input);
return new _ParseAST(input, location, tokens, this._reflector, false).parseTemplateBindings();