Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: tools/dom/templates/html/impl/impl_HTMLTemplateElement.darttemplate

Issue 19663011: Custom Syntax's are now enabled via template.bindingDelegate = (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: restore @Experimental Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/dom/templates/html/impl/impl_Element.darttemplate ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // WARNING: Do not edit - generated code. 5 // WARNING: Do not edit - generated code.
6 6
7 part of $LIBRARYNAME; 7 part of $LIBRARYNAME;
8 8
9
10 /** 9 /**
11 * Model-Driven Views (MDV)'s native features enables a wide-range of use cases, 10 * Model-Driven Views (MDV)'s native features enables a wide-range of use cases,
12 * but (by design) don't attempt to implement a wide array of specialized 11 * but (by design) don't attempt to implement a wide array of specialized
13 * behaviors. 12 * behaviors.
14 * 13 *
15 * Enabling these features in MDV is a matter of implementing and registering an 14 * Enabling these features in MDV is a matter of implementing and registering an
16 * MDV Custom Syntax. A Custom Syntax is an object which contains one or more 15 * MDV Custom Syntax. A Custom Syntax is an object which contains one or more
17 * delegation functions which implement specialized behavior. This object is 16 * delegation functions which implement specialized behavior. This object is
18 * registered with MDV via [TemplateElement.syntax]: 17 * registered with MDV via [Element.bindingDelegate]:
19 * 18 *
20 * 19 *
21 * HTML: 20 * HTML:
22 * <template bind syntax="MySyntax"> 21 * <template bind>
23 * {{ What!Ever('crazy')->thing^^^I+Want(data) }} 22 * {{ What!Ever('crazy')->thing^^^I+Want(data) }}
24 * </template> 23 * </template>
25 * 24 *
26 * Dart: 25 * Dart:
27 * class MySyntax extends CustomBindingSyntax { 26 * class MySyntax extends BindingDelegate {
28 * getBinding(model, path, name, node) { 27 * getBinding(model, path, name, node) {
29 * // The magic happens here! 28 * // The magic happens here!
30 * } 29 * }
31 * } 30 * }
32 *
33 * ... 31 * ...
34 * 32 * query('template').bindingDelegate = new MySyntax();
35 * TemplateElement.syntax['MySyntax'] = new MySyntax(); 33 * query('template').model = new MyModel();
36 * 34 *
37 * See <https://github.com/polymer-project/mdv/blob/master/docs/syntax.md> for 35 * See <https://github.com/polymer-project/mdv/blob/master/docs/syntax.md> for
38 * more information about Custom Syntax. 36 * more information about Custom Syntax.
39 */ 37 */
40 // TODO(jmesserly): if this is just one method, a function type would make it 38 // TODO(jmesserly): move this type to the MDV package? Two issues: we'd lose
41 // more Dart-friendly. 39 // type annotation on [Element.bindingDelegate], and "mdv" is normally imported
40 // with a prefix.
42 @Experimental() 41 @Experimental()
43 abstract class CustomBindingSyntax { 42 abstract class BindingDelegate {
44 /** 43 /**
45 * This syntax method allows for a custom interpretation of the contents of 44 * This syntax method allows for a custom interpretation of the contents of
46 * mustaches (`{{` ... `}}`). 45 * mustaches (`{{` ... `}}`).
47 * 46 *
48 * When a template is inserting an instance, it will invoke this method for 47 * When a template is inserting an instance, it will invoke this method for
49 * each mustache which is encountered. The function is invoked with four 48 * each mustache which is encountered. The function is invoked with four
50 * arguments: 49 * arguments:
51 * 50 *
52 * - [model]: The data context for which this instance is being created. 51 * - [model]: The data context for which this instance is being created.
53 * - [path]: The text contents (trimmed of outer whitespace) of the mustache. 52 * - [path]: The text contents (trimmed of outer whitespace) of the mustache.
(...skipping 28 matching lines...) Expand all
82 * instance. 81 * instance.
83 * - [model]: The data context for which this instance is being created. 82 * - [model]: The data context for which this instance is being created.
84 * 83 *
85 * The template element will always use the return value of `getInstanceModel` 84 * The template element will always use the return value of `getInstanceModel`
86 * as the model for the new instance. If the syntax does not wish to override 85 * as the model for the new instance. If the syntax does not wish to override
87 * the value, it should simply return the `model` value it was passed. 86 * the value, it should simply return the `model` value it was passed.
88 */ 87 */
89 getInstanceModel(Element template, model) => model; 88 getInstanceModel(Element template, model) => model;
90 } 89 }
91 90
92
93 @Experimental() 91 @Experimental()
94 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { 92 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
95 $!MEMBERS 93 $!MEMBERS
96 94
97 // For real TemplateElement use the actual DOM .content field instead of 95 // For real TemplateElement use the actual DOM .content field instead of
98 // our polyfilled expando. 96 // our polyfilled expando.
99 @Experimental() 97 @Experimental()
100 DocumentFragment get content => $dom_content; 98 DocumentFragment get content => $dom_content;
101 99
102 100
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 tr[template], 282 tr[template],
285 td[template], 283 td[template],
286 caption[template], 284 caption[template],
287 colgroup[template], 285 colgroup[template],
288 col[template], 286 col[template],
289 option[template] { 287 option[template] {
290 display: none; 288 display: none;
291 }'''; 289 }''';
292 document.head.append(style); 290 document.head.append(style);
293 } 291 }
294
295 /**
296 * A mapping of names to Custom Syntax objects. See [CustomBindingSyntax] for
297 * more information.
298 */
299 @Experimental()
300 static Map<String, CustomBindingSyntax> syntax = {};
301 } 292 }
OLDNEW
« no previous file with comments | « tools/dom/templates/html/impl/impl_Element.darttemplate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698