fillInfunction
Put values into a string's braces: fillIn("Bid {n}", { n: 3 }) is "Bid 3". A brace with no value is left as it is.
Import it
import { fillIn } from "@johnmorrisdotca/toranpu";
Definition
function fillIn(template: string, values: Record<string, string | number>): string
Parameters
| Name | Type | Description |
|---|---|---|
template | string | The text with named braces to fill. |
values | Record<string, string | number> | Replacement values keyed by the braces in the template. |
Returns
string
Put values into a string's braces: fillIn("Bid {n}", { n: 3 }) is "Bid 3". A brace with no value is left as it is.
Examples
import { fillIn } from "@johnmorrisdotca/toranpu";
console.log(fillIn("Seat {seat}: {name}", { seat: 1, name: "Aki" }));Seat 1: AkiWhat it prints (run when this page was built)