Output hidden fields on pages other than templates

When a page other than a template is being edited, output the template
name and preview page name in hidden fields, so that users using scripts
to use TemplateSandbox on non-templates don't have to re-enter them
every time they preview.

Change-Id: Ibf612b3e7a92a80cbb983e534737cc343a3c1cbe
Merge "Output hidden fields on pages other than templates"