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

Unified Diff: pkg/mdv/lib/src/template.dart

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/mdv/lib/mdv.dart ('k') | pkg/mdv/lib/src/template_iterator.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/mdv/lib/src/template.dart
diff --git a/pkg/mdv/lib/src/template.dart b/pkg/mdv/lib/src/template.dart
index a1713d1ccbc0c0ca92d241a5a507f6ff3cae921b..3424bbc8191fc498e745a98dd65aa5ef4fd5ef42 100644
--- a/pkg/mdv/lib/src/template.dart
+++ b/pkg/mdv/lib/src/template.dart
@@ -7,7 +7,9 @@ part of mdv;
/** Extensions to [Element]s that behave as templates. */
class _TemplateExtension extends _ElementExtension {
var _model;
+ BindingDelegate _bindingDelegate;
_TemplateIterator _templateIterator;
+ bool _scheduled = false;
_TemplateExtension(Element node) : super(node);
@@ -50,16 +52,16 @@ class _TemplateExtension extends _ElementExtension {
/**
* Creates an instance of the template.
*/
- DocumentFragment createInstance(model, String syntax) {
+ DocumentFragment createInstance(model, BindingDelegate delegate) {
var template = node.ref;
if (template == null) template = node;
var instance = _createDeepCloneAndDecorateTemplates(
- template.content, syntax);
+ template.content, delegate);
if (_instanceCreated != null) _instanceCreated.add(instance);
- _addBindings(instance, model, TemplateElement.syntax[syntax]);
+ _addBindings(instance, model, delegate);
_addTemplateInstanceRecord(instance, model);
return instance;
}
@@ -70,8 +72,29 @@ class _TemplateExtension extends _ElementExtension {
get model => _model;
void set model(value) {
- var syntax = TemplateElement.syntax[node.attributes['syntax']];
_model = value;
- _addBindings(node, model, syntax);
+ _ensureSetModelScheduled();
+ }
+
+ /**
+ * The binding delegate which is inherited through the tree. It can be used
+ * to configure custom syntax for `{{bindings}}` inside this template.
+ */
+ BindingDelegate get bindingDelegate => _bindingDelegate;
+
+ void set bindingDelegate(BindingDelegate value) {
+ _bindingDelegate = value;
+ _ensureSetModelScheduled();
+ }
+
+ _ensureSetModelScheduled() {
+ if (_scheduled) return;
+ _scheduled = true;
+ runAsync(_setModel);
+ }
+
+ void _setModel() {
+ _scheduled = false;
+ _addBindings(node, _model, _bindingDelegate);
}
}
« no previous file with comments | « pkg/mdv/lib/mdv.dart ('k') | pkg/mdv/lib/src/template_iterator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698