@@ -0,0 +1,2574 @@
+package de.morphbit.thymeleaf.service.impl;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0Aimport java.io.Reader;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport org.attoparser.AbstractMarkupHandler;%0Aimport org.attoparser.MarkupParser;%0Aimport org.attoparser.ParseException;%0Aimport org.attoparser.config.ParseConfiguration;%0Aimport org.attoparser.dom.Element;%0A%0Apublic abstract class AbstractElementParser extends AbstractMarkupHandler %7B%0A%0A%09protected final String dialectPrefix;%0A%0A%09private List%3CElement%3E elements;%0A%09private Element currentElement;%0A%0A%09public AbstractElementParser(String dialectPrefix) %7B%0A%09%09this.dialectPrefix = dialectPrefix;%0A%09%7D%0A%0A%09protected List%3CElement%3E parseElements(String file) %7B%0A%09%09return parseElements(Thread.currentThread().getContextClassLoader()%0A%09%09    .getResourceAsStream(file));%0A%09%7D%0A%0A%09protected List%3CElement%3E parseElements(InputStream stream) %7B%0A%09%09this.elements = new ArrayList%3C%3E();%0A%0A%09%09try (Reader reader = new InputStreamReader(stream)) %7B%0A%09%09%09final ParseConfiguration config =%0A%09%09%09        ParseConfiguration.htmlConfiguration();%0A%0A%09%09%09final ParseConfiguration autoCloseConfig =%0A%09%09%09        ParseConfiguration.htmlConfiguration();%0A%09%09%09autoCloseConfig.setElementBalancing(%0A%09%09%09    ParseConfiguration.ElementBalancing.AUTO_OPEN_CLOSE);%0A%0A%09%09%09final MarkupParser htmlStandardParser = new MarkupParser(config);%0A%09%09%09htmlStandardParser.parse(reader, this);%0A%0A%09%09%7D catch (IOException %7C ParseException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D finally %7B%0A%09%09%09try %7B%0A%09%09%09%09if (stream != null) %7B%0A%09%09%09%09%09stream.close();%0A%09%09%09%09%7D%0A%09%09%09%7D catch (IOException e) %7B%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09return this.elements;%0A%09%7D%0A%0A%09@Override%0A%09public void handleAttribute(char%5B%5D buffer, int nameOffset, int nameLen,%0A%09        int nameLine, int nameCol, int operatorOffset, int operatorLen,%0A%09        int operatorLine, int operatorCol, int valueContentOffset,%0A%09        int valueContentLen, int valueOuterOffset, int valueOuterLen,%0A%09        int valueLine, int valueCol) throws ParseException %7B%0A%09%09String attributeName = new String(buffer, nameOffset, nameLen);%0A%09%09String attributeValue =%0A%09%09        new String(buffer, valueContentOffset, valueContentLen);%0A%09%09if (currentElement != null) %7B%0A%09%09%09currentElement.addAttribute(attributeName, attributeValue);%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09public void handleOpenElementStart(char%5B%5D buffer, int nameOffset,%0A%09        int nameLen, int line, int col) throws ParseException %7B%0A%09%09String attributeName = new String(buffer, nameOffset, nameLen);%0A%09%09this.currentElement = new Element(attributeName);%0A%09%09this.elements.add(currentElement);%0A%09%7D%0A%0A%7D%0A

Add AbstractElementParser to parse template files