| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:html'; | 5 import 'dart:html'; |
| 6 | 6 |
| 7 import 'package:polymer_expressions/polymer_expressions.dart'; | 7 import 'package:polymer_expressions/polymer_expressions.dart'; |
| 8 import 'package:template_binding/template_binding.dart' show templateBind; | 8 import 'package:template_binding/template_binding.dart' show templateBind; |
| 9 | 9 |
| 10 // We use mirrors for illustration purposes, but ideally we would generate a |
| 11 // static configuration with smoke/static.dart. |
| 12 import 'package:smoke/mirrors.dart'; |
| 13 |
| 14 // Since we use smoke/mirrors, we need to preserve symbols used in the template. |
| 15 // This includes String.startsWith, List.take, and Person. |
| 16 @MirrorsUsed(targets: const [String, List, Person]) |
| 17 import 'dart:mirrors'; |
| 18 |
| 10 import 'person.dart'; | 19 import 'person.dart'; |
| 11 | 20 |
| 12 main() { | 21 main() { |
| 22 useMirrors(); |
| 13 var john = new Person('John', 'Messerly', ['A', 'B', 'C']); | 23 var john = new Person('John', 'Messerly', ['A', 'B', 'C']); |
| 14 var justin = new Person('Justin', 'Fagnani', ['D', 'E', 'F']); | 24 var justin = new Person('Justin', 'Fagnani', ['D', 'E', 'F']); |
| 15 var globals = { | 25 var globals = { |
| 16 'uppercase': (String v) => v.toUpperCase(), | 26 'uppercase': (String v) => v.toUpperCase(), |
| 17 'people': [john, justin], | 27 'people': [john, justin], |
| 18 }; | 28 }; |
| 19 | 29 |
| 20 templateBind(querySelector('#test')) | 30 templateBind(querySelector('#test')) |
| 21 ..bindingDelegate = new PolymerExpressions(globals: globals) | 31 ..bindingDelegate = new PolymerExpressions(globals: globals) |
| 22 ..model = john; | 32 ..model = john; |
| 23 | 33 |
| 24 templateBind(querySelector('#test2')).model = john; | 34 templateBind(querySelector('#test2')).model = john; |
| 25 } | 35 } |
| OLD | NEW |