Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jweinst1/formstringsjs
A simple way to get python-like format strings in JavaScript
https://github.com/jweinst1/formstringsjs
Last synced: 6 days ago
JSON representation
A simple way to get python-like format strings in JavaScript
- Host: GitHub
- URL: https://github.com/jweinst1/formstringsjs
- Owner: jweinst1
- Created: 2016-01-29T18:08:05.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-29T18:16:14.000Z (almost 9 years ago)
- Last Synced: 2024-10-13T23:46:15.184Z (about 1 month ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#FormStringsJS
A simple addon for Node to make easy Template Strings in JavaScript.
##Installation
To Install FormStringsJS, simply type in your shell:
`npm install formstringsjs`
##Usage
To use the package, you have to require it, then use the FormString() function to transform your strings.
This function takes two arguments, the first, is the string you wish to format. The second, is a JavaScript object that contains the
mappings of keys to values that will be replaced in your format string. Here is an example:You have the string `"I love {fruit} so much."`, and you can format that string with the object `{"fruit":"apples"}`.
The result will be `"I love apples so much."`. Please note though, you cannot have multiple bracket names in the same string, or else an error will be returned.