Ensure integer template index to prevent hard TypeError failure.