Convert a Go template into a JS template function