Instalation:
In Node or browserify:
- Run
npm install altr
. - in your module:
var altr = require('altr')
Otherwise:
- Download altr.js from here
- include it in your html before your other JavaScript files
Basic Usage:
- {% tab %}
var state = {name: "world", list: [1, 2, 3, 4, 5]}
var template = altr(document.getElementById('root'), state)
var i = 5
setInterval(function() {
state.list.push(++i)
state.list = state.list.slice(-5)
template.update(state)
}, 1000)
<div id="root">
<h1>hello, {{ name }}!</h1>
If you highlight an item below, you can see how elements are bound to data.
<ul altr-for="item in list">
<li altr-text="item"></li>
</ul>
</div>