Strip leading and trailing whitespace from templates

This allows jQuery to parse the rendered template as HTML, since the first
character of the template needs to be a '<'.