Do other similar systems in PHP really just write plain HTML into their code? How is it possible for them to maintain consistency? Is that all done manually within the theme?
Just had a look at Wordpress, they seem to have a mix of templates that call functions from a standard API and functions that embed the HTML directly. The functions are overridden by themes. Then they also have the shortcode system to embed functions into content.
One pattern I see is that they use quite "programmery" things to to generate the list of classnames, then just insert the result in as text e.g.:
$css_class = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
$output .= $indent . '' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after . '';
from: https://github.com/WordPress/WordPress/blob/master/wp-includes/post-template.php
I'd kind of been working on the principle that if you could cope with imploding filtered arrays then you'd be happy enough calling a function to generate the HTML. But maybe people just ignore the scarier bits and change the stuff they recognise?