Forked from omarkdev/vuejs-filter-camel-case-filter.js
Created
February 8, 2018 16:00
-
-
Save sorindorobantu/3ea1347ee3af760e33e2a8adea6c578c to your computer and use it in GitHub Desktop.
VueJS filter camel case
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
/** | |
* Converts a string to camel case. | |
* Example: fucking_string => fuckingString | |
* | |
* @param {String} str the string to convert | |
* @return {String} | |
*/ | |
Vue.filter('camelCase', function (str) { | |
return str.toLowerCase() | |
.replace( /[-_]+/g, ' ') | |
.replace( /[^\w\s]/g, '') | |
.replace( / (.)/g, function($1) { return $1.toUpperCase(); }) | |
.replace( / /g, '' ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment