OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 import 'dart:html'; | |
6 | |
7 import 'package:polymer_expressions/polymer_expressions.dart'; | |
8 import 'package:template_binding/template_binding.dart' show templateBind; | |
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 | |
19 import 'person.dart'; | |
20 | |
21 main() { | |
22 useMirrors(); | |
23 var john = new Person('John', 'Messerly', ['A', 'B', 'C']); | |
24 var justin = new Person('Justin', 'Fagnani', ['D', 'E', 'F']); | |
25 var globals = { | |
26 'uppercase': (String v) => v.toUpperCase(), | |
27 'people': [john, justin], | |
28 }; | |
29 | |
30 templateBind(querySelector('#test')) | |
31 ..bindingDelegate = new PolymerExpressions(globals: globals) | |
32 ..model = john; | |
33 | |
34 templateBind(querySelector('#test2')).model = john; | |
35 } | |
OLD | NEW |