Temple
A modern JavaScript view framework.
- Modular & Extensible - Views are encapsulated, reusable components, making testing and separation of concerns easy.
- Data Neutral - Temple is focused purely on the View aspect of web applications and can be easily integrated with existing frameworks and platforms.
- Lightweight - Temple has no external dependencies and weighs in at just under 30KB minified.
- Reactive - Keep the interface up-to-date flexibly with auto-running computations powered by Meteor's dependency package.
Note: This library is under active development. Use at your own risk!
Install
Download the latest version from our release page and use via a script tag. The variable Temple
will be attached to window
.
<script type="text/javascript" src="temple.js"></script>
If using Browserify or Node.js, you can install via NPM and use via require("templejs")
.
$ npm install templejs
Example
var Clock = Temple.Text.extend({
constructor: function() {
Temple.Text.call(this, Clock.getTime());
},
beforeMount: function(comp) {
this.interval = setInterval(this.invalidate.bind(this), 500);
},
onStop: function() {
clearInterval(this.interval);
delete this.interval;
},
render: function() {
this.setValue(Clock.getTime());
}
}, {
getTime: function() {
var date = new Date;
return [
date.getHours(),
date.getMinutes(),
date.getSeconds()
].map(function(digit) {
return (digit < 10 ? "0" : "") + digit;
}).join(":");
}
});
new Clock().paint("body").mount();