Skip to content

Instantly share code, notes, and snippets.

@kkiernan
kkiernan / vuejs-filter-snake-to-title.js
Last active December 6, 2021 12:34
A Vue.js filter that converts snake case to title case.
/**
* 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);