0.0.2 • Published 10 years ago

ractive-adaptors-modella v0.0.2

Weekly downloads
3
License
GPL v2
Repository
github
Last release
10 years ago

Ractive-adaptors-modella

Build Status

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: 'river.grimm@gmail.com'});

view = new Ractive({
    template: '<span>{{name}} - {{email}}</span>',
    data: user,
    adapt: [modellaAdaptor([User]);]
});

user.name('River Grimm');

view.toHTML(); // <span>River Grimm - river.grimm@gmail.com</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

0.0.2

10 years ago

0.0.1

10 years ago