package de.morphbit.thymeleaf.base;

import org.junit.BeforeClass;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.templatemode.TemplateMode;
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;

import de.morphbit.thymeleaf.dialect.ComponentDialect;

public class AbstractThymeleafComponentDialectTest {

	private static TemplateEngine templateEngine;

	@BeforeClass
	public static void beforeClass() {
		setupThymeleaf();
	}

	private static void setupThymeleaf() {
		ClassLoaderTemplateResolver templateResolver =
		        new ClassLoaderTemplateResolver();
		templateResolver.setCacheable(false);
		templateResolver.setCharacterEncoding("UTF-8");
		templateResolver.setTemplateMode(TemplateMode.HTML);

		templateEngine = new TemplateEngine();
		templateEngine.setTemplateResolver(templateResolver);
		final ComponentDialect dialect = new ComponentDialect();
		templateEngine.addDialect(dialect.getPrefix(), dialect);
	}
}

@@ -97,16 +97,54 @@
 Engine;%0A
+import org.thymeleaf.context.Context;%0A
 import o
@@ -305,16 +305,86 @@
 Dialect;
+%0Aimport de.morphbit.thymeleaf.parser.StandardThymeleafComponentParser;
 %0A%0Apublic
@@ -431,16 +431,71 @@
 Test %7B%0A%0A
+%09private static final String BASE_PATH = %22templates%22;%0A%0A
 %09private
@@ -608,16 +608,165 @@
 ();%0A%09%7D%0A%0A
+%09protected String processThymeleafFile(String fileName, Context context) %7B%0A%09%09return templateEngine.process(BASE_PATH + %22/%22 + fileName, context);%0A%09%7D%0A%0A
 %09private
@@ -1035,16 +1035,55 @@
 e.HTML);
+%0A%09%09templateResolver.setSuffix(%22.html%22);
 %0A%0A%09%09temp
@@ -1228,24 +1228,202 @@
 tDialect();%0A
+%09%09final StandardThymeleafComponentParser parser =%0A%09%09        new StandardThymeleafComponentParser(%22%22, %22.html%22,%0A%09%09            %22templates/components%22);%0A%09%09dialect.addParser(parser);%0A
 %09%09templateEn

Complete configuration