ractive-adaptors-modella
v0.0.2
Published
modella adaptor for ractive.js
Downloads
3
Readme
Ractive-adaptors-modella
Ractive adaptor plugin for modella.
Installation
Component:
component install staygrimm/ractive-adaptors-modella
npm:
npm install ractive-adaptors-modella
Example
var modellaAdaptor = require('ractive-adaptors-modella'),
modella = require('modella'),
Ractive = require('ractive'),
User,
user
User = modella('User')
.attr('name')
.attr('email');
user = new User({name: 'River', email: '[email protected]'});
view = new Ractive({
template: '<span>{{name}} - {{email}}</span>',
data: user,
adapt: [modellaAdaptor([User]);]
});
user.name('River Grimm');
view.toHTML(); // <span>River Grimm - [email protected]</span>
API
Adaptor([constructors])
Unline other Ractive adaptors, we need to initialize this adaptor with an array of Modella constructors. This is required as there's no easy method to discover if a model has been created by Modella. Instead, we have to check against the constructors Modella returns.
Test
npm install && make test
License
GPL v2