Domenic Denicola (2014-03-07T02:51:48.000Z)
domenic at domenicdenicola.com (2014-03-20T16:16:42.932Z)
Tagged template strings are one of my favorite parts of ES6. I include them and generators in my ["ES6 The Awesome Parts" talk][1]. Sample uses from that slide deck, most of them cribbed from the wiki: ```js // Contextual auto-escaping qsa`.${className}`; safehtml`<a href="${url}?q=${query}" onclick="alert('${message}')" style="color: ${color}">${message}</a>`; // Localization and formatting l10n`Hello ${name}; you are visitor number ${visitor}:n! You have ${money}:c in your account!` // Regexes re`\d+${separator}\d+` // Embedded HTML/XML jsx`<a href="${url}">${text}</a>` // becomes React.DOM.a({ href: url }, text) // DSLs for code execution var childProcess = sh`ps ax | grep ${pid}`; var xhr = POST`http://example.org/service?a=${a}&b=${b} Content-Type: application/json Authorization: ${credentials} { "foo": ${foo}, "bar": ${bar} }`; ``` [1]: http://www.slideshare.net/domenicdenicola/es6-the-awesome-parts/23