Skip to content

Instantly share code, notes, and snippets.

@tracend
Created January 15, 2014 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tracend/8434259 to your computer and use it in GitHub Desktop.
Save tracend/8434259 to your computer and use it in GitHub Desktop.
_.ucwords() #underscore #helper #cc
_.mixin({
// Uppercase the first character of each word in a string
// From: http://phpjs.org/functions/ucwords/
ucwords : function(str) {
return (str + '').replace(/^([a-z])|\s+([a-z])/g, function ($1) {
return $1.toUpperCase();
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment