Skip to content

Instantly share code, notes, and snippets.

@ckarande
Created December 29, 2015 04:51
Show Gist options
  • Save ckarande/d8b48a78d987213b9a3a to your computer and use it in GitHub Desktop.
Save ckarande/d8b48a78d987213b9a3a to your computer and use it in GitHub Desktop.
ES6 Tagged Template Example
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