Temple
A modern JavaScript view framework. http://beneaththeink.com/temple
- 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 - The main Temple source has been kept to only the absolute essentials. All extras are available as external packages.
- Reactive - Keep the interface up-to-date with auto-running computations powered by Trackr.
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();