I'm an advocate of avoiding inline html in javascript wherever possible. In Form Builder, I've been using [underscore's templates](http://underscorejs.org/#template).

Example usage:
- https://github.com/dimagi/Vellum/blob/master/templates/main.html#L74
- https://github.com/dimagi/Vellum/blob/master/js/ui.js#L251

Is it possible for you do to something similar here?