You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 13, 2018. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -136,7 +136,7 @@ MDV is designed to as two primitives which could eventually become standardized
136
136
137
137
MDV is mainly concerned with being robust and efficient in interacting with application data and keeping the DOM in sync , but more advanced behaviors can be accomplished via one or both of the following:
A Custom Syntax is an object which contains one or more syntax methods which implement specialized behavior. This object is registered with MDV via the HTMLTemplateElement. The syntax need only implement syntax methods it requires to accomplish its goals.
50
-
51
-
```JavaScript
52
-
var syntax = {
53
-
getBinding:function(model, path, name, node) {},
54
-
getInstanceModel:function(template, model) {}
55
-
};
56
-
HTMLTemplateElement.syntax['name'] = syntax;
57
-
```
58
-
59
-
### Custom Syntax Usage
60
-
61
-
The `<template>` element can declare its intent to use a Custom Syntax by naming it in its `syntax` attribute:
62
-
63
-
```html
64
-
<templatesyntax="MyCustomSyntaxName">
65
-
...
66
-
</template>
67
-
```
68
-
69
-
If a `syntax` can be located via the registry by the `<template>`, the syntax's methods will be called to possibly override its default behavior.
70
-
71
-
When a `<template>` inserts an new instance fragment into the DOM,
72
-
73
-
* If a syntax used and located
74
-
* ...and it contains sub-templates
75
-
* ...and the sub-template does not have a syntax attribute
76
-
77
-
... Then the sub-template will "inherit" the parent's syntax. e.g.:
78
-
79
-
```html
80
-
<templatebindsyntax="FooSyntax">
81
-
<!-- FooSyntax is used here -->
82
-
<templatebind>
83
-
<!-- FooSyntax is used here -->
84
-
</template>
85
-
<templatesyntax="OtherSyntax">
86
-
<!-- OtherSyntax is used here, NOT FooSyntax -->
87
-
</template>
88
-
</template>
89
-
```
90
41
### getBinding
91
42
92
-
The `getBinding`syntax method allows for a custom interpretation of the contents of mustaches (`{{` ... `}}`).
43
+
The `getBinding` method allows for a custom interpretation of the contents of mustaches (`{{` ... `}}`).
93
44
94
45
When a template is inserting an instance, it will invoke the `getBinding` method (if it is implemented by the syntax) for each mustache which is encountered. The function is invoked with four arguments:
* `name`: The context in which the mustache occurs. Within element attributes, this will be the name of the attribute. Within text, this will be 'textContent'.
103
54
* `node`: A reference to the node to which this binding will be created.
104
55
105
-
If the `getBinding` syntax method wishes to handle binding, it is required to return an object which has at least a `value` property. If it does, then MDV will call
56
+
If the `getBinding` method wishes to handle binding, it is required to return an object which has at least a `value` property. If it does, then MDV will call
106
57
107
58
```JavaScript
108
59
node.bind(name, retval, 'value');
@@ -114,7 +65,7 @@ If the 'getBinding' wishes to decline to override, it should not return a value.
114
65
115
66
### getInstanceModel
116
67
117
-
The `getInstanceModel` syntax method allows a syntax to provide an alterate model than the one the template would otherwise use when producing an instance.
68
+
The `getInstanceModel` method allows a syntax to provide an alterate model than the one the template would otherwise use when producing an instance.
118
69
119
70
When a template is about to create an instance, it will invoke the `getInstanceModel` method (if it is implemented by the syntax). The function is invoked with two arguments:
120
71
@@ -128,7 +79,7 @@ The template element will always use the return value of `getInstanceModel` as t
128
79
129
80
### CompoundBinding
130
81
131
-
MDV contains a helper object which is useful for the implementation of a Custom Syntax.
82
+
MDV contains a helper object which is useful for the implementation of a Binding Delegate.
0 commit comments