Properly replace template.

Avoid having to assume a magic variable is present in scope.