React-like inline styles for Marionette Views
To use this Marionette Behavior, be sure to add it to the behaviorLookup.
import StyleBehavior from 'backbone.marionette.style';
Marionette.Behaviors.behaviorsLookup = function() {
return {
Style: StyleBehavior
};
};
After you've done this you can add the Style behavior to one of your views, like so:
var StyleView = Marionette.ItemView.extend({
template: _.template('<div></div>'),
behaviors: {
Style: {}
},
style: {
backgroundColor: '#000',
color: 'white',
fontSize: 14,
position: 'absolute'
}
});
This module uses code from Facebook React to generate the css from the style object. Their licenses apply.
Also uses the basic setup for the plugin from Backbone.Storage.