| 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);
|
| }
|
| }
|
|
|