[Digression: to display code in Discourse threads, I recommend either using fenced code blocks (three backticks) or indented code blocks (four spaces). That way you don’t have to escape your backticks like you do with inline code.]
Yes, you should use embedded expressions in your template literals to insert dynamic values into your HTML or Markdown.
If you put a SCRIPT element in an HTML tagged template literal,
it gets added to the DOM, but the script doesn’t get executed. That’s standard behavior, per the HTML5 specification, e.g.
When inserted using the
script elements execute (typically blocking further script execution or HTML parsing), but when inserted using
outerHTML attributes, they do not execute at all.
Only “parser-inserted” scripts (those that exist in the HTML at the time the page was loaded) are executed. Scripts that are created dynamically and added to the DOM are not executed.