public TNode parse(Path path) {
   try {
     final TNode root = parse(Files.readAllBytes(path), TemplateType.fromPath(path));
     root.setUnparsedSize(Files.size(path));
     return root;
   } catch (IOException e) {
     throw new TemplateException(e);
   } catch (TemplateException e) {
     if (e.getCause() != null) {
       throw new TemplateException(
           "Error when parsing " + path + ":" + e.getCause().getMessage(), e.getCause());
     } else {
       throw new TemplateException("Error when parsing " + path + ":" + e.getMessage(), e);
     }
   }
 }