grunt-processhtml icon indicating copy to clipboard operation
grunt-processhtml copied to clipboard

Template literals (Template strings) Failing To Process

Open ronnievsmith opened this issue 3 years ago • 3 comments

Are template strings supported? I am getting the following error from Grunt:

Fatal error: myTemplateStringVar is not defined

My variable looks like below and runs fine in all three major web browsers.

myTemplateStringVar = "xyz";
let thisDt = fragment.querySelector(`dt[data-label=${myTemplateStringVar}]`);

ronnievsmith avatar Nov 02 '22 03:11 ronnievsmith

Hi @ronnieroyston template strings or string interpolation with backticks, is a javascript feature and it has nothing to do with this plugin or grunt.

There is nothing wrong in the code example you shared. I would need more context on where are you running this code specifically to understand what is it that is failing. something I can reproduce

dciccale avatar Nov 02 '22 09:11 dciccale

Thanks for the response Denis. When I remove the newly added template string lines of code the files get built with Grunt. It's a large js file.

The error message was:

Running "processhtml:dist" (processhtml) task
Fatal error: myTemplateStringVar is not defined

ronnievsmith avatar Nov 03 '22 01:11 ronnievsmith

make sure the variable is available in the scope you're using it. i can't help you much more than that without some example. it seems more like a javascript mistake on your code rather than an issue with this particular plugin, I could be wrong but without something to reproduce it is very hard for me to help. if i can get some time later I can make a demo/test to show how variables actually should work fine. but i don't know where are you using that code, is it in your gruntfile or where?

dciccale avatar Nov 03 '22 11:11 dciccale