node package manager

repit

Repeat it

Loop over the items of an array store and append bound instances of that element.

Repit has been built for brick and wall but also work as a standalone library.

Installation

with component:

$ component install bredele/repit

with browserify:

$ npm install repit

Standalone

Repit uses cement to sync each item with a datastore.

HTML:

<ul>
  <li>{{ label }}</li>
</ul>

JavaScript:

var Store = require('datastore');
var Repeat = require('repit');
 
var data = new Store([{
  label: 'bredele'
}, {
  label: 'Calgary'
}
]);
 
 
var list = new Repeat(data);
list.scan(ul);
 

Result:

<ul>
  <li>bredele</li>
  <li>Calgary</li> 
</ul>

See example.

Brick

Directive:

<ul repeat>
  <li>{{ label }}</li>
</ul>

Brick:

var brick = require('brickjs');
var repeat = require('repit');
 
var view = brick(ul)
  .use(repeat())
  .build();

repeat will automatically use the brick data if nothing is passed.

update the ui :

view.set(0, {
  label: 'something'
});
 
view.reset([{
  label: 'bredele',
}, {
  label: 'Calgary'
}])

See example.

Wall

var repeat = require('repit');
var wall = require('wall');
 
var app = wall();
app.use(repeat);
 
app.repeat(node, data);

See example.

License

MIT