Using 'replace' instead of 'substring' to strip template names from paths