https://github.com/gwendall/meteor-template-states
Template states for Blaze
https://github.com/gwendall/meteor-template-states
Last synced: about 2 months ago
JSON representation
Template states for Blaze
- Host: GitHub
- URL: https://github.com/gwendall/meteor-template-states
- Owner: gwendall
- Created: 2015-03-13T16:13:35.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-08-07T14:20:25.000Z (almost 8 years ago)
- Last Synced: 2025-04-04T22:46:59.575Z (about 2 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 13
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
```diff
- NOTE: This package is not maintained anymore.
- If you want to help, please reach out to [email protected]
```Meteor Template States
=================Template states for Blaze
Installation
------------``` sh
meteor add gwendall:template-states
```Methods
----------**template.state(key)**
Gets a template state**template.state(key, value)**
Sets a template stateExample
-------Declare your states in ```onCreated``` hooks
``` javascript
Template.post.onCreated(function() {
this.state('loading', false);
})
```The states are then available in your templates.
``` javascript
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
});
}
})
`````` html
{{#if loading}}
Loading...
{{/if}}
```