I maintain the lit-html template library which uses JavaScript tagged template literals to embed HTML in JS.
A key feature of JS template literals is that the tag receives the string fragments and values separately, and can return non-string results. This means we can escape values and validate template structure to prevent XSS attacks.
This approach in Java should lead to a lot more lightweight but safe DSL embeddings.
(I don't love the syntax, but... it's Java)
edit: the other critical feature of JS tagged template literals, that I'm not sure this has, is referential equality of the template strings passed to the tag function across multiple invocations.
This is required to be able to do one-time preparation work on a template and re-use that with different sets of values. Think a `SQL.` template processor that turns the strings into a prepared statement once and re-uses that for each query with different parameters.
edit 2: awesome, it does:
The fragments() of a StringTemplate are constant across all evaluations of a template expression, while values() is computed fresh for each evaluation. For example: