Trim HTML strings in templates before passing to jQuery