Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
riot mixin for converting opts.class to a list.
(function(riot) {
/** resets the classlist from tag options. */
var listClasses = function(tag) {
tag.classlist = tag.opts.class ? tag.opts.class.split(/\s+/) : [];
};
var mixin = {
init: function() {
listClasses(this);
this.on('before-update', function() { listClasses(this); }.bind(this));
},
/** conatiner for classnames. */
classlist: [],
/**
* gets the classlist as a string.
*
* @return string space-separated list of classnames
*/
classes: function() { return this.classlist.join(' '); }
};
riot.mixin('classlister', mixin);
})(riot);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment