In (syntax) version 8 and later, individual variables may be printed HTML-escaped or not (overriding current htmlmode) via $+var or $-var, respectively. See here for details.