[1.7.x] Fixed #23114 -- Clarified documentation of template lookups.

Thanks to gmunumel and Tom Dalton for their help on the patch.

Backport of 62c74abbb06a081708c2cb5cc459f39beb26acaa from master.