Htmx and datastar use backend rendering. So you write the html in the backend and serve that. In the case of an array, you render them as Todo ítems.
You might be using a template system for that. E.g. Jinja2, moustache, askama, templ, etc depending on your backend language and libraries.