Skip to content

Instantly share code, notes, and snippets.

@petermoresi
Last active October 30, 2015 15:49
Show Gist options
  • Save petermoresi/79e4c72c107d935a4ec9 to your computer and use it in GitHub Desktop.
Save petermoresi/79e4c72c107d935a4ec9 to your computer and use it in GitHub Desktop.
String.raw and ES6 template strings
let a = 1, b = 2, foo="foo", bar="bar", credentials: "insecure";
String.raw`http://foo.org/bar?a=${a}&b=${b}
Content-Type: application/json
X-Credentials: ${credentials}
{ "foo": ${foo},
"bar": ${bar}}`;
/* The code above produces the result
"http://foo.org/bar?a=1&b=2
Content-Type: application/json
X-Credentials: undefined
{ "foo": foo,
"bar": bar}"
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment