dt-list
v0.1.4
Published
Δt list controller - async & dynamic templating engine
Downloads
7
Maintainers
Readme
Δt dynamictemplate List Controller
This provides List handling support for asyncxml and Δt.
Installation
$ npm install dt-list
Usage
var List = require('dt-list').List; // server
var List = dynamictemplate.List; // browser
function myTemplate(view) {
var that = this;
var items = new List;
view.on('add', function (model) {
items.push(that.$li(function () {
this.$p(model.text);
}));
});
view.on('insert', function (i, model) {
items.insert(i, that.$li(function () {
this.$p(model.text);
}));
});
view.on('remove', function (i) {
var el;
if (typeof i === 'undefined')
el = items.remove(i);
else
el = items.shift();
if (el) el.remove();
});
}
api
Same api like Order but you don't have to give functions anymore, that does List
for you. Just throw your Δt elements created with asyncxml into the List
like your would throw values into javascripts Array
.