move template generation out of remote helper

Change-Id: If0f81d16b44b8dfd9e668ba8ba16a05d72a2f616
Reviewed-on: http://review.couchbase.org/36815
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Li Yang <lichenyang2@gmail.com>