Refractor getTemplateName function to avoid issue when namespace is bigger than 3 entries.