Ractive adaptor for modella
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.gitignore
.travis.yml
LICENSE.txt
Makefile
README.md
component.json
index.js
package.json

README.md

I no longer use Ractive and this repo is not maintained

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

MIT