Avoid the use of instance variables in partials

These were added in 6b67fadd93a06286ef47d6861134f238f4db6ce4, and @edds
pointed out the problem. I think it was an oversight caused by us starting
with the logic in a template and then moving it into the partial.