With some caveats^, Swift's result builders are probably the nicest templating system I've used. It's expressive enough kinda look like what you're moddeling.
For example with the HTML DSL ElementaryUI:
ul {
for item in listOfSomething {
li { item.string }
}
}
Yet you're still fully in the programming language you're in.
Result builders have pretty much convinced me that any language that might at any point be used to generate UIs should seriously consider having some kind of DSL feature like this.
Having it fully integrated into the language in a natural way makes generating UIs and similar things so much more natural to deal with.
And don't talk to me about these dedicated templating languages. In those you typically loose strong typing (among other things) completely, forcing you to find mistakes at run time instead of compile time.