Use FormatJson::encode() for escaping template JS

htmltentities() is not appropriate for escaping the content passed to the
Google JS block.  Use FormatJson::encode() instead.

Change-Id: I91c1f13fdaf06fd24ce7afd5d2309388234d1f59