code: private static String toCanonicalName(String key, String root) {
          if (key.startsWith("/") || key.startsWith("\\")) {
              key = key.substring(1);
          }
          if (key.startsWith(root)) {
              key = key.replace(root, "");
          }
          if (key.startsWith("/") || key.startsWith("\\")) {
              key = key.substring(1);
          }
          //if (-1 != pos) key = key.substring(0, pos);
          key = key.replace('/', '.').replace('\\', '.');
          return key;
      }
docs: Convert the key to canonical template name
  
  @param key  the resource key
  @param root the resource loader root path
  @return the canonical name