Template states for Blaze
- NOTE: This package is not maintained anymore.
- If you want to help, please reach out to [email protected]
Template states for Blaze
meteor add gwendall:template-states
template.state(key) Gets a template state
template.state(key, value) Sets a template state
Declare your states in onCreated
hooks
Template.post.onCreated(function() {
this.state('loading', false);
})
The states are then available in your templates.
Template.post.events({
'submit form': function(e, tpl) {
tpl.state('loading', true);
Meteor.call('post.create', { ... }, function(err, res) {
tpl.state('loading', false);
// Do something else
});
}
})
<template name="post">
{{#if loading}}
Loading...
{{/if}}
</template>