diff --git a/lib/interpolate.dart b/lib/interpolate.dart index 13a0643fe..5c01297a2 100644 --- a/lib/interpolate.dart +++ b/lib/interpolate.dart @@ -9,7 +9,7 @@ num endSymbolLength = endSymbol.length; class Interpolate { Parser $parse; ExceptionHandler $exceptionHandler; - + Interpolate(Parser this.$parse, ExceptionHandler this.$exceptionHandler); ParsedFn call(String text, [bool mustHaveExpression = false]) { @@ -54,7 +54,7 @@ class Interpolate { if (chunk == null) { chunk = ''; } else if (!(chunk is String)) { - chunk = toJson(chunk); + chunk = '$chunk'; } } concat.add(chunk); diff --git a/test/interpolate_spec.dart b/test/interpolate_spec.dart index ecd5cac3f..9d72a46d0 100644 --- a/test/interpolate_spec.dart +++ b/test/interpolate_spec.dart @@ -1,5 +1,9 @@ import "_specs.dart"; +class ToStringableObject { + toString() => 'World'; +} + main() { describe('\$interpolate', () { @@ -48,6 +52,11 @@ main() { expect($interpolate("Hello {{'World' + foo()}}")($rootScope)).toEqual('Hello World'); })); + it('should use toString to conver objects to string', inject((Interpolate $interpolate, Scope $rootScope) { + $rootScope.obj = new ToStringableObject(); + expect($interpolate("Hello, {{obj}}!")($rootScope)).toEqual('Hello, World!'); + })); + describe('parseBindings', () { it('should Parse Text With No Bindings', inject((Interpolate $interpolate) {