#22572 Tweaks to hooks to better support optional name in templates