https://github.com/alvarocastro/placeholdify
Simple placeholder utility for strings
https://github.com/alvarocastro/placeholdify
placeholder placeholders replace sprintf string strings
Last synced: 23 days ago
JSON representation
Simple placeholder utility for strings
- Host: GitHub
- URL: https://github.com/alvarocastro/placeholdify
- Owner: alvarocastro
- License: mit
- Created: 2019-09-10T01:14:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-25T01:04:35.000Z (over 3 years ago)
- Last Synced: 2025-01-25T11:26:18.034Z (over 1 year ago)
- Topics: placeholder, placeholders, replace, sprintf, string, strings
- Language: JavaScript
- Homepage:
- Size: 1.29 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# placeholdify
[](https://www.npmjs.com/package/placeholdify)
[](https://github.com/alvarocastro/placeholdify/actions?query=workflow%3Abuild)
[](https://codeclimate.com/github/alvarocastro/placeholdify/maintainability)
[](https://coveralls.io/github/alvarocastro/placeholdify?branch=master)
[](https://bundlephobia.com/result?p=placeholdify)
[](https://github.com/xojs/xo)
[](https://github.com/semantic-release/semantic-release)
Simple function to put placeholders in strings.
- [Install](#install)
- [Usage](#usage)
- [Contributing](#contributing)
- [Support](#support)
## Install
```bash
npm install placeholdify
```
## Usage
```js
const placeholdify = require('placeholdify');
placeholdify('foo {1} baz {0}', 'qux', 'bar');
//=> foo bar baz qux
```
### placeholdify(format[, value[, ...]])
#### format
Type: `string`
String containing the placeholders.
Placeholders must be in the format `{n}` (example: `{0}`, `{1}`, etc.), being `n` the index of the value to insert into.
#### value
Type: `mixed`
Values to insert into the `format` string.
## Contributing
Contributions are always welcome! Please run `npm test` beforehand to ensure everything is ok.
## Support
If you use this package please consider starring it :)