ES6 offers template strings, such as
`Hello ${name}`
In this case a default template builder is called. You can also use your own "tags":
tag`Hello ${name}`
where tag
is a function which is passed information about the template string and generates a result.
My question is, is there any way to override the default function called when no tag is specified?
Another question: Is there any way to determine if the tag function is being called by the system to construct a template string, versus say being called directly, other than examining the first argument for a raw
property?
No. They are different syntactic productions with different semantic meanings. `stuff`
is more akin to a string literal, whereas tag`stuff`
is more akin to a function call.