Moodle in English -> Themes -> Flat Bootswatch -> Re: Flat Bootswatch
It seems strange for the FRONTEND team to be investigating/suggesting the use of template engines in renderers, presumably so that they are easier to write for people who know HTML, while also having a policy that recommends using such an obtuse, verbose and unfriendly API for simple HTML. It's as if we're officially pretending that Moodle is written in Java rather than PHP. After all, PHP itself is one of the "template engines" the front end team is considering since it's had this ability to blend code and HTML built into the language from day one.
Note I'm aware that html_writer is useful in situations where you're passing variables about and changing them before rendering something at the end, similar to your example. I wrote something very similar myself, except that it produce more idiomatic HTML5, and I believe this is the task that html_writer was originally created for. But for writing out what would otherwise be a mostly static bit of HTML it's just silly how much extra typing is involved and how unreadable the result is.