Loop over the items of a datastore and append bound instances of that element.
JavaScript CSS
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
test
.gitignore
History.md
Makefile
Readme.md
component.json
index.js
package.json

Readme.md

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