Added simple validation, and output escaping to js templates