https://github.com/alexeyraspopov/string-interpolate
Simple string interpolation
https://github.com/alexeyraspopov/string-interpolate
Last synced: 5 months ago
JSON representation
Simple string interpolation
- Host: GitHub
- URL: https://github.com/alexeyraspopov/string-interpolate
- Owner: alexeyraspopov
- Created: 2014-03-16T15:43:53.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-06-19T06:50:14.000Z (almost 11 years ago)
- Last Synced: 2024-12-01T03:34:19.418Z (5 months ago)
- Language: JavaScript
- Size: 196 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# String interpolate
Simple string interpolation
## Install
```bash
$ npm install string-interpolate
``````bash
$ component install alexeyraspopov/string-interpolate
``````bash
$ bower install string-interpolate
```## API
interpolate(template, data);
* `template` - template string. Default delimiters are `{}`
* `data` - simple object## Usage
var interpolate = require('string-interpolate');
interpolate('{ greeting }, { user.name }', {
greeting: 'Hello',
user: {
name: 'Jane'
}
});
If `data` is not specified - returns template functionvar greet = interpolate('Hello { name }');
greet({ name: 'Jane' }); // Hello Jane
greet({ name: 'Mike' }); // Hello Mike
## License[MIT License](http://en.wikipedia.org/wiki/MIT_License) (c) Alexey Raspopov