Last active
February 6, 2017 14:03
-
-
Save Go7hic/6c21640a6300b42339179f0430276cb2 to your computer and use it in GitHub Desktop.
ES6 字符串模板渲染函数 #tags: ES6
This file contains 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 render (template, options) { | |
return template.replace(/\{\{\s?(\w+)\s?\}\}/g, (match, variable) => { | |
return options[variable] || '' | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment