improved html rendering for templates