Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jorgeramirez/strinter
Small string interpolation module for JavaScript
https://github.com/jorgeramirez/strinter
Last synced: 23 days ago
JSON representation
Small string interpolation module for JavaScript
- Host: GitHub
- URL: https://github.com/jorgeramirez/strinter
- Owner: jorgeramirez
- Created: 2012-09-22T02:38:22.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2012-09-22T14:06:06.000Z (about 12 years ago)
- Last Synced: 2024-04-08T18:16:03.387Z (7 months ago)
- Language: JavaScript
- Size: 105 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# strinter
Small string interpolation (Python-like) module for JavaScript. It works in Node and the Browser. Keep in
mind that this is a work in progress, so there are things that needs to be done.## Usage
The following code snippet works in Node```javascript
var strinter = require('./strinter').strinter;// pass an object
var data = {name: 'Jorge', lastname: 'Ramirez', age: 22};
var out = strinter('Hello I am %(name)s %(lastname)s. I\'m %(age)d years old', data);
console.log(out);
```And the browser version looks like the following
```html
// pass an object
var data = {name: 'Jorge', lastname: 'Ramirez', age: 22};
var out = strinter('Hello I am %(name)s %(lastname)s. I\'m %(age)d years old', data);
console.log(out);```
## TODO
* Support '+', '-' and '0' convertion flags.
* Support the following convertion types: 'f', 'g', 'G', 'x', 'X' and 'o'.## License
`strinter` is licensed under [GPLv3](http://www.gnu.org/licenses/gpl.txt)