Function: template()
ts
function template(value, data): string;Replaces {key} placeholders in a string with values from a data object. 使用数据对象中的值替换字符串中的 {key} 占位符。
Parameters
| Parameter | Type | Description |
|---|---|---|
value | string | The template string / 模板字符串 |
data | Record<string, unknown> | The interpolation data / 插值数据 |
Returns
string
The interpolated string / 插值后的字符串
Example
ts
template('Hi, {name}', { name: 'Tom' })
// => 'Hi, Tom'Since
1.2.0