embedded a modified version of template.HTMLEscapeString