| 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 part of mdv; | 5 part of mdv; |
| 6 | 6 |
| 7 /** Extensions to [Element]s that behave as templates. */ | 7 /** Extensions to [Element]s that behave as templates. */ |
| 8 class _TemplateExtension extends _ElementExtension { | 8 class _TemplateExtension extends _ElementExtension { |
| 9 var _model; | 9 var _model; |
| 10 _TemplateIterator _templateIterator; | 10 _TemplateIterator _templateIterator; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * Creates an instance of the template. | 51 * Creates an instance of the template. |
| 52 */ | 52 */ |
| 53 DocumentFragment createInstance(model, String syntax) { | 53 DocumentFragment createInstance(model, String syntax) { |
| 54 var template = node.ref; | 54 var template = node.ref; |
| 55 if (template == null) template = node; | 55 if (template == null) template = node; |
| 56 | 56 |
| 57 var instance = _createDeepCloneAndDecorateTemplates( | 57 var instance = _createDeepCloneAndDecorateTemplates( |
| 58 template.content, syntax); | 58 template.ref.content, syntax); |
| 59 | 59 |
| 60 if (_instanceCreated != null) _instanceCreated.add(instance); | 60 if (_instanceCreated != null) _instanceCreated.add(instance); |
| 61 | 61 |
| 62 _addBindings(instance, model, TemplateElement.syntax[syntax]); | 62 _addBindings(instance, model, TemplateElement.syntax[syntax]); |
| 63 _addTemplateInstanceRecord(instance, model); | 63 _addTemplateInstanceRecord(instance, model); |
| 64 return instance; | 64 return instance; |
| 65 } | 65 } |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * The data model which is inherited through the tree. | 68 * The data model which is inherited through the tree. |
| 69 */ | 69 */ |
| 70 get model => _model; | 70 get model => _model; |
| 71 | 71 |
| 72 void set model(value) { | 72 void set model(value) { |
| 73 var syntax = TemplateElement.syntax[node.attributes['syntax']]; | 73 var syntax = TemplateElement.syntax[node.attributes['syntax']]; |
| 74 _model = value; | 74 _model = value; |
| 75 _addBindings(node, model, syntax); | 75 _addBindings(node, model, syntax); |
| 76 } | 76 } |
| 77 } | 77 } |
| OLD | NEW |