Last active
December 6, 2021 12:34
-
-
Save kkiernan/91298079d34f0f832054 to your computer and use it in GitHub Desktop.
A Vue.js filter that converts snake case to title 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 snake case string to title case. | |
* Example: snake_case => Snake Case | |
* | |
* @param {String} str the string to convert | |
* @return {String} | |
*/ | |
Vue.filter('snakeToTitle', function (str) { | |
return str.split('_').map(function (item) { | |
return item.charAt(0).toUpperCase() + item.substring(1); | |
}).join(' '); | |
}); |
export function toPascalCase(stringInput) {
return stringInput.split('_').map(_.capitalize).join('');
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!
If using components: