Last active
August 31, 2015 09:10
-
-
Save larchanka/c15bb26157a20d0afba1 to your computer and use it in GitHub Desktop.
Function generateClasses generates classes string from a passed object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* generateClasses generates classes string from a passed object, i.e. | |
generateClasses({ | |
'class1': true, | |
'class2': false, | |
'class3': true | |
}); | |
// will return string 'class1 class3' | |
*/ | |
(function() { | |
this.generateClasses = function generateClasses(classesObject) { | |
var cl = [], clName; | |
if(typeof classesObject !== 'object') { | |
return; | |
} | |
for(clName in classesObject) { | |
if(classesObject[clName] === true) { | |
cl.push(clName); | |
} | |
} | |
return cl.join(' '); | |
}; | |
}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment