Added support for templatePath with trailing backslash.