Skip to content

Instantly share code, notes, and snippets.

@Torsten85
Created December 19, 2013 10:34
Show Gist options
  • Save Torsten85/8037304 to your computer and use it in GitHub Desktop.
Save Torsten85/8037304 to your computer and use it in GitHub Desktop.
When directly referencing a template in the inclusion tag, the templating engine reactively updates this template. If a helper method that returns a template component is used, the template is rerendered.
<head>
<title>template</title>
</head>
<body>
{{> testB}}
</body>
<template name="testA">
{{#each items}}
{{> item}}
{{/each}}
</template>
<template name="testB">
{{#each items}}
{{> getTemplate}}
{{/each}}
</template>
<template name="item">
{{name}}<br>
</template>
if (Meteor.isClient) {
var Items = new Meteor.Collection('items', {connection: null});
var id = Items.insert({name: 'Test Item'});
setTimeout(function () {
Items.update({_id: id}, {name: 'Updated Test Item'});
}, 2000);
Template.item.rendered = function () {
// This should only trigger once.
console.log('Item rendered from scratch');
};
Template.testB.getTemplate = function () {
return Template['item'];
};
UI.body.items = function () {
return Items.find();
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment