Correctly resolving promise of the template body to function