UNPKG

@intlayer/core

Version:

Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.

21 lines (20 loc) 437 B
//#region src/interpreter/getInsertion.ts /** * Allow to insert values in a string. * * Usage: * * ```ts * const content = getInsertion('Hello {{name}}!', { * name: 'John', * }); * // 'Hello John!' * ``` * */ const getInsertion = (content, values) => content.replace(/\{\{\s*(.*?)\s*\}\}/g, (_, key) => { return (values[key.trim()] ?? "").toString(); }); //#endregion export { getInsertion }; //# sourceMappingURL=getInsertion.mjs.map