Created
April 16, 2021 22:15
-
-
Save plugn/c74ad0400da12411c5d63d04eab42648 to your computer and use it in GitHub Desktop.
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 characters
function template(source, scope = {}) { | |
return String(source).replace(/\{\{(.+?)\}\}/gm, function(match, p1) { | |
const param = p1.trim() | |
return scope[param] || '' | |
}).replace(/ +/mg, ' ') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment