Fix infinite loop introduced with f3f0252d9b6313b7977a40be321b789dc2965bb1

If the template content didn't match the regex, it would loop indefinitely