3 ms·
to give a clear answer here, tagged templates don't actually perform string concat. the function being used as the tag receives an array of the string literals,
by snek 8y ago
to give a clear answer here, tagged templates don't actually perform string concat. the function being used as the tag receives an array of the string literals, and the rest of the arguments as the values passed in templates, and can perform any processing it wishes at that point. I've seen some js sql libraries actually using this to prevent people from having the exact problem you're complaining about.
- dmitriid 8y agoHowever, the main darling of tagged templates, lit-html does exactly that: parsing, concatenating, then doing an element.innerHtml So does HTM we discuss here. I quickly googled. sql-tag and node-sql-template-strings do a lot of string concatenation (well, of course, they have to create a SQL statement out of values passed in). sql-template parses and concatenates. Because it's really basically all you can do, be cause tag`string` is just a function call tag("string"). There's no magic.
- snek 8y agoits actually more like tag`string ${x}` is tag(['string', ''], x)