EugeneXa mentioned it in a comment, but it deserves to be an answer:
var template = $("#modal_template").html().trim();
This trims the offending whitespace from the beginning of the string. I used it with Mustache, like so:
var markup = Mustache.render(template, data);
$(markup).appendTo(container);