Syntax for loops and conditionals introducing scopes to your document may work fine for plain text documents, but in my experience it turns structured documents like HTML in unreadable mess very fast. I don't know why it's a de facto standard for template engines to make it this way.
I came up with the idea of attaching conditions and loop specifications directly to XML tags, and in my opinion it significantly improves readability. I couldn't find any alternative with similar syntax, so I've implemented it myself. It's also in C++, although it works as a transpiler, and templates are needed to be compiled. It can be found here: https://github.com/kamchatka-volcano/hypertextcpp
Don't judge me, as I don't use it anywhere besides personal projects)