Files
selfdefined/node_modules/@11ty/eleventy/src/Util/Capitalize.js
tatianamac 6d5445ecc5 update
2019-11-26 14:50:43 -08:00

21 lines
386 B
JavaScript

module.exports = function(str, options) {
options = Object.assign(
{
lowercaseRestOfWord: false
},
options
);
return str
.split(" ")
.map(function(word) {
return (
word.substr(0, 1).toUpperCase() +
(options.lowercaseRestOfWord
? word.substr(1).toLowerCase()
: word.substr(1))
);
})
.join(" ");
};