https://github.com/dnbard/stringyjs
https://github.com/dnbard/stringyjs
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/dnbard/stringyjs
- Owner: dnbard
- Created: 2014-05-11T19:05:10.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-05-13T18:42:29.000Z (about 12 years ago)
- Last Synced: 2025-01-26T05:41:20.049Z (over 1 year ago)
- Language: JavaScript
- Size: 152 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#StringyJS
Javascript library for working with strings.
##Instalation
* Download minified version `stringy.min.js` or debug ready version `stringy.js` of library from `dist` folder.
* Put `` to your html file
##Initialization
StringyJS is AMD ready. You can use RequireJS or not use it (this way you can use StringyJS methods from window.Stringy global object).
###Capitalize
Capitalizes the first character in the string. If `all` is true, all words in the string will be capitalized.
Stringy.capitalize(string[, all]);
Stringy.capitalize('capitalize one word');
=> Capitalize one word
Stringy.capitalize('capitalize all words', true);
=> Capitalize All Words
###Contain
Returns true if the string matches search criteria(search for `what` in `where`). It may be a string or regex.
Stringy.contain(where, what);
Stringy.contain('Summertime', 'Summer');
=> True
Stringy.contain('What is love?', /love/);
=> True
###Templates
Assigns variables to tokens in a string. If an object is passed, it's properties can be assigned using the object's keys `{name}`, otherwise it can be accessed by the argument number beginning with `0`.
Stringy.template(template[, *arguments]);
Stringy.template('This is {0}!', 'template');
=> This is template!
Stringy.template('This is {param} template {what}', {
param: 'named',
what: 'placeholder'
});
=> This is named template placeholder