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.
@emord @dannyroberts you'll need to run `bower update underscore` after this branch gets merged. Otherwise tests will fail in your local dev env.