${variable} notation in string?


#1

Using a sample I found (re: renderer.js), it indicates use of {} to create a string, but it doesn't work for me. Another sample similarly does not work. Any thoughts on what might be wrong with the "{path}" in the string below? It just prints "You selected: {path}" rather than filling-in {path} with the contents of the path variable.

ipc.on(‘selectedItem’, function (event, path) {
document.getElementById(‘selectedItem’).innerHTML = ‘You selected: ${path}’
})


#2

Template literals:

es5 string build: var sayHello = "Hello " + name;

es6 template literals: sayHello =`Hello ${name}`;`

Note the quotes that wrap the string in es6 are ` not '… (same key as ~).


#3

That works! I never noticed that ` and ’ were different characters in the sample!

Thanks!!