- 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.
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.
// create a view instance from a template and datavar tpl = Temple;// render and append to the document bodytpl;// later, change the value and watch it auto-update the DOMtpldataname = "John";
Listening for DOM events is really easy in Temple. Enable the plugin and then add an
on-<event> attribute to any element.
// create a view instance from just a templatevar tpl = Temple// enable the DOM events plugin// add the special alert action// render and append to the document body;
Temple even lets you turn your views into reusable components.
// a reusable View classvar Hello = Temple;// render a new template that uses the view as a partialvar tpl = Temple;// views can also be rendered directlyvar tpl2 = name: "World" ;