Skip to content

Instantly share code, notes, and snippets.

@crongro
Last active April 3, 2017 08:38
Show Gist options
  • Save crongro/378a681146389d3ed04d7c98b56859b7 to your computer and use it in GitHub Desktop.
Save crongro/378a681146389d3ed04d7c98b56859b7 to your computer and use it in GitHub Desktop.
es6_template_literal
function fn(val, name, hour) {
var ampm = (hour > 11) ? "pm" : "am";
console.log(val[0], name, val[1], hour, ampm, val[2]);
}
var data = {
hour : new Date().getHours(),
name : "solvin"
}
const template = fn`<div><span>hello! ${data.name}, current time is ${data.hour}</span></div>`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment