A Vue.js plugin provides a filter and a function to titlecase a string.
- Vue.js
^1.0.24
The algorithm is based on the gamma rule described as follows:
Glossary of Grammatical and Rhetorical Terms: title case (capitalization)
$ npm install vue-titlecase$ bower install vue-titlecasevar Vue = require('vue')
var Titlecase = require('vue-titlecase')
// set plugin
Vue.use(Titlecase)
// create instance
new Vue({
el: '#test-titlecase',
data: {
msg: "hello world! my id is starfish. I LOVE WATCHing tv.",
}
})Template the following:
<div id="test-titlecase" class="message">
<p>{{ msg | titlecase }}</p>
<p>{{ msg.toTitleCase() }}</p>
</div>Output the following:
<div id="test-titlecase" class="message">
<p>Hello World! My ID is Starfish. I Love Watching TV.</p>
<p>Hello World! My ID is Starfish. I Love Watching TV.</p>
</div>Converts a string instance to the titlecase form. Returns a new string.
This is a customized Vue filter used to converts the string representation of an object to the titlecase form.
- Fork it !
- Create your top branch from
dev:git branch my-new-topic origin/dev - Commit your changes:
git commit -am 'Add some topic' - Push to the branch:
git push origin my-new-topic - Submit a pull request to
devbranch ofHaixing-Hu/vue-titlecaserepository !
First you should install all depended NPM packages. The NPM packages are used for building and testing this package.
$ npm installThen install all depended bower packages. The bower packages are depended by this packages.
$ bower installNow you can build the project.
$ gulp buildThe following command will test the project.
$ gulp testThe following command will perform the test and generate a coverage report.
$ gulp test:coverageThe following command will perform the test, generate a coverage report, and upload the coverage report to coveralls.io.
$ gulp test:coverallsYou can also run bower install and gulp build together with the following
command:
npm run buildOr run bower install and gulp test:coveralls together with the following
command:
npm run test