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
-[inheritsHelpersFrom(templateName), inheritsEventsFrom(templateName), and inheritsHooksFrom(templateName)](#inheritshelpersfromtemplatename-inheritseventsfromtemplatename-and-inheritshooksfromtemplatename)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
22
39
23
40
## Installation
24
41
25
42
```bash
26
43
$ meteor add aldeed:template-extension
27
44
```
28
45
46
+
## Compatibility
47
+
48
+
- Use a 3.x.x release with Meteor 1.0.x or Meteor 1.1.x
49
+
- Use a 4.x.x release with Meteor 1.2+
50
+
29
51
## Template.forEach(callback)
30
52
31
53
Call `callback` once for each defined template. Generally, you'll want to call this in a `Meteor.startup` function or sometime after all templates have been loaded.
Use this instead of setting created/rendered/destroyed property directly. You can call it multiple times to attach multiple hooks to the same template.
72
+
An alternative syntax to `onCreated`, `onRendered`, and `onDestroyed`.
47
73
48
74
```js
49
75
Template.foo.hooks({
@@ -82,9 +108,11 @@ Template.foo.hooks({
82
108
*client.js*
83
109
84
110
```js
85
-
Template.foo.bar=function () {
86
-
return"TEST";
87
-
};
111
+
Template.foo.helpers({
112
+
bar:function () {
113
+
return"TEST";
114
+
}
115
+
});
88
116
89
117
Template.foo.events({
90
118
'click button':function (event, template) {
@@ -99,6 +127,8 @@ Whenever `{{> foo}}` is used, the contents of the `foo2` template will be shown
99
127
100
128
This is useful when a package you are using defines a template for something and you'd like to adjust some things in that template for your app.
101
129
130
+
NOTE: This simply swaps the render function. Helpers, callbacks, and events assigned to `foo2` will not fire when `{{> foo}}` is used. Only the `foo` helpers, callbacks, and events are used.
131
+
102
132
## inheritsHelpersFrom(templateName), inheritsEventsFrom(templateName), and inheritsHooksFrom(templateName)
103
133
104
134
*html*
@@ -147,6 +177,10 @@ In this example, both templates are rendered. Both use the `bar` helper defined
147
177
148
178
Additionally, these methods can be called with an array of template names: `Template.foo2.inheritsHooksFrom(['foo', 'bar', 'baz']);`
149
179
180
+
## clearEventMaps()
181
+
182
+
After `Template.foo.events({...})` has been called one or more times, you can remove all the added event handlers by calling `Template.foo.clearEventMaps()`
183
+
150
184
## copyAs(newTemplateName)
151
185
152
186
*html*
@@ -204,7 +238,7 @@ they are not.
204
238
## template.get(fieldName)
205
239
206
240
To not have to hard-code the number of levels when accessing parent template instances you can use
207
-
`get(fieldName)` method which returns the value of the first field named `fieldName`in the current
241
+
`get(fieldName)` method which returns the value of the first property named `fieldName`on the current
208
242
or ancestor template instances, traversed in the hierarchical order. It traverses block helper template
209
243
instances as well. This pattern makes it easier to refactor templates without having to worry about
210
244
changes to number of levels.
@@ -223,7 +257,7 @@ var data = Template.parentData(function (data) {return data instanceof MyDocumen
223
257
224
258
## Contributors
225
259
226
-
*@aldeed ([Support via Gratipay](https://gratipay.com/aldeed/))
0 commit comments