1.0.0 • Published 4 years ago
stringin v1.0.0
stringin
A teeny-weeny utility to programatically interpolate ES6 string templates.
Get Started
Install as a dependency in the console:
npm i stringin
Import and use in your JS/TS project:
import interpolate from 'stringin'
// Define your template with '${}'s inside
const template = 'There are ${choreCount} chores to do today'
// Then interpolate with static values
interpolate(template, { choreCount: 4 })
// 'There are 4 chores to do today'
// Or use a function to get a value
interpolate(template, { choreCount: () => 2 + 5 })
// 'There are 7 chores to do today'
Usage
replace (template, data)
Parameters:
Name | Type | Description |
---|---|---|
template | string | The template string containing the different ${fieldNames} . |
data | Object | The data to insert into the template. |
Returns:
Type: String
1.0.0
4 years ago