Created
December 29, 2015 04:51
-
-
Save ckarande/d8b48a78d987213b9a3a to your computer and use it in GitHub Desktop.
ES6 Tagged Template Example
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 tag(strings,...values) { | |
let newStr = ""; | |
console.log(strings); | |
console.log(strings.join()); | |
values.forEach(function(value, i) { | |
console.log(value, i) | |
newStr += strings[i] + 'contents for widget' + value | |
}); | |
newStr += strings[strings.length -1]; | |
console.log(newStr); | |
} | |
const template = tag` | |
<div> | |
<widget>${1}</widget> | |
<div> | |
<div> | |
<widget>${2}</widget> | |
</div>`; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment