SI-8367 Fix positioning of extends, super in bodyless templates

A refinement of the fix in ac779096.