Correctly references 'this' within templates