Temple
A JavaScript view framework.
- Reactive - Powered by Trackr, Temple automatically updates the DOM as data changes.
- Template Driven - Use a Mustache-HTML hybrid syntax to quickly generate UI scaffolding.
- Modular & Extensible - All views are encapsulated, reusable components.
- Data Neutral - Temple can be easily integrated with existing frameworks and platforms.
Example
Here is a basic example of using Temple. This just uses a simple variable, but Temple has support for most of the major Mustache features.
var tpl = Temple.render("<h1>Hello {{ name }}</h1>", { name: "World" });
tpl.paint("body");
tpl.data.name = "John";
Listening for DOM events is really easy in Temple. Enable the plugin and then add an on-<event>
attribute to any element.
var tpl = Temple.render("<a href='#' on-click='alert'>Click Me</a>")
.use("actions")
.addAction("alert", function(e) {
e.original.preventDefault();
alert("You clicked me!");
})
.paint("body");
Temple even lets you turn your views into reusable components.
var Hello = Temple.extend({
template: "Hello {{ name }}"
});
var tpl = Temple.render("<h1>{{> hello }}</h1>", { name: "John" })
.setPartial("hello", Hello)
.paint("body");
var tpl2 = new Hello({ name: "World" }).paint("body");