@intlayer/core
Version:
Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.
23 lines (21 loc) • 523 B
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
//#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
exports.getInsertion = getInsertion;
//# sourceMappingURL=getInsertion.cjs.map