Skip to content

Instantly share code, notes, and snippets.

@Go7hic
Last active February 6, 2017 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Go7hic/6c21640a6300b42339179f0430276cb2 to your computer and use it in GitHub Desktop.
Save Go7hic/6c21640a6300b42339179f0430276cb2 to your computer and use it in GitHub Desktop.
ES6 字符串模板渲染函数 #tags: ES6
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