In Python you can do this:
bar = "hello world"
template = t"<something foo={bar} />"
string = html(template)
This is simply not possible in JS, because the template literal always must have the tag attached. You can't split them apart. If you try: const bar = "hello world"
const template = `<something foo=${bar} />`
you already have a string in the `template` variable. There's no access to the individual values anymore. It's already done. It's a string. No template. You can't pull apart the literal declaration and the tagging.Are we now done with this ridiculous game of deliberate misunderstandings?
let passthrough = (...args) => args;
let bar = "hello world";
let template = passthrough`<something foo=${bar} />`;
string = html(...template);Now, I'll just ignore that you're still deliberately misrepresenting me in the hopes of gaining some actual knowledge from this discussion - please show me: which editor supports syntax highlighting for the specific example you just mentioned? After all, that was the topic of discussion - not whether it's possible to delay "tagging", but whether it's easier to do syntax highlighting for JS template tags. Please show me an existing editor, IDE or git repo for a tool that would highlight your specific example based on the `html(...template)` call in line 4 (so no heuristics based on line 3). Surely you're not just throwing random examples at the wall to see what sticks, right? You've actually been following the discussion and are arguing in the context of it?
Python should be able to detect the magic syntactic pattern just the same way JS does and use that for syntax higlighting. In JS the magic syntactic pattern for triggering HTML syntax highlighting is:
html`<doc/>`
In Python the magic syntactic pattern would be: html(t"<doc />")
My point in showing that JS counterexample was to demonstrate that the real reason people don't do that kind of thing isn't that they can't, it's that they like having syntax highlighting. That means the approach should work just as well in Python. This is the case even though the heuristic involved is very weak. Changing the name of the identifier or breaking into multiple expressions would be enough to break the heuristic in either language, which is why I think it's a really weak heuristic and dangerous pitfall for developers who might mistake the coloring for information about how the runtime sees that data (which is normally what syntax highlighting is for)Had you not played games with this technicality, we could both have saved a lot of time. Hope you had fun I guess.