GuobaGuoba Utils

template

@guoba-ai/utils / string / template

Function: template()

function template(str, data): string;

Defined in: string.ts:59

Simple template string replacement. Replaces {key} placeholders with values from the data object.

Parameters

str

string

The template string with {key} placeholders

data

Record<string, string>

Object with replacement values

Returns

string

The string with placeholders replaced

Example

template('Hello {name}!', { name: 'World' }) // 'Hello World!'

On this page