feat(change_detection): add support for pipes in the template

This commit is contained in:
vsavkin
2015-02-20 10:59:14 -08:00
parent 29f5ee0c29
commit 987a5fdf56
12 changed files with 138 additions and 134 deletions

View File

@ -5,7 +5,7 @@ import {MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
import {Parser} from 'angular2/src/change_detection/parser/parser';
import {Lexer} from 'angular2/src/change_detection/parser/lexer';
import {ContextWithVariableBindings} from 'angular2/src/change_detection/parser/context_with_variable_bindings';
import {Formatter, LiteralPrimitive} from 'angular2/src/change_detection/parser/ast';
import {Pipe, LiteralPrimitive} from 'angular2/src/change_detection/parser/ast';
class TestData {
a;
@ -340,8 +340,8 @@ export function main() {
});
});
it("should error when using formatters", () => {
expectEvalError('x|blah').toThrowError(new RegExp('Cannot have a formatter'));
it("should error when using pipes", () => {
expectEvalError('x|blah').toThrowError(new RegExp('Cannot have a pipe'));
});
it('should pass exceptions', () => {
@ -367,16 +367,16 @@ export function main() {
});
describe("parseBinding", () => {
describe("formatters", () => {
it("should parse formatters", () => {
describe("pipes", () => {
it("should parse pipes", () => {
var exp = parseBinding("'Foo'|uppercase").ast;
expect(exp).toBeAnInstanceOf(Formatter);
expect(exp).toBeAnInstanceOf(Pipe);
expect(exp.name).toEqual("uppercase");
});
it("should parse formatters with args", () => {
it("should parse pipes with args", () => {
var exp = parseBinding("1|increment:2").ast;
expect(exp).toBeAnInstanceOf(Formatter);
expect(exp).toBeAnInstanceOf(Pipe);
expect(exp.name).toEqual("increment");
expect(exp.args[0]).toBeAnInstanceOf(LiteralPrimitive);
});