Created
November 2, 2020 08:13
-
-
Save kenjinp/93c446a19b50cba50eb621aad1056f26 to your computer and use it in GitHub Desktop.
Revisions
-
kenjinp renamed this gist
Nov 2, 2020 . 1 changed file with 3 additions and 1 deletion.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 @@ -1,9 +1,11 @@ import { get } from 'lodash'; // will result in template parsing inside js-like template-string literals: ${ } // for example ${myObject.name} const templateStringExpression = /\${([^}]*)}/g; const templater = (sourceObject: object, templateString: string) => { return templateString.replace( templateStringExpression, (match: string, group1: string) => { -
kenjinp created this gist
Nov 2, 2020 .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,14 @@ // will result in template parsing inside js-like template-string literals: ${ } // for example ${myObject.name} const templateStringExpression = /\${([^}]*)}/g; const parseMarkdown = (sourceObject: object, templateString: string) => { return templateString.replace( templateStringExpression, (match: string, group1: string) => { const value = get(sourceObject, group1); return value; } ); };