Model repeat writer refactor

Refactor the writer, similar to what was done in https://github.com/dimagi/Vellum/pull/284

Best reviewed commit-by-commit.
Mug-specific XML writing is now associated with the mug rather than special cased in the writer module.