Created
February 9, 2023 05:30
-
-
Save qutek/d75afedab924278de925267d8f8d10dc to your computer and use it in GitHub Desktop.
Revisions
-
qutek created this gist
Feb 9, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ const replacePlaceholder = (template, data) => { try { return template.replace(/{(\w+)}/g, (keyVariable, keyData) => data.hasOwnProperty(keyData) ? data[keyData] : variable ); } catch (error) { console.error('replacePlaceholder', error); throw error; } };