Returning HTML code in a render function is even pretty standard, I've seen this in Python / Flask too.
Judging code quality is hard, it seems to me the best clue is how it is easy to add new features / do refactors without breaking things, not how you feel about PHP and HTML being mixed.
Looks like a mess with code cutting and pasting HTML together, escaping things without a clear plan. That’s a sign of a million security problems waiting to happen.
Returning HTML code in a render function is even pretty standard, I've seen this in Python / Flask too.
Judging code quality is hard, it seems to me the best clue is how it is easy to add new features / do refactors without breaking things, not how you feel about PHP and HTML being mixed.