use of org.thymeleaf.templateresolver.ClassLoaderTemplateResolver in project gs-spring-security-3.2 by rwinch.
the class WebMvcConfiguration method templateResolver.
@Bean
public ClassLoaderTemplateResolver templateResolver() {
ClassLoaderTemplateResolver result = new ClassLoaderTemplateResolver();
result.setPrefix("views/");
result.setSuffix(".html");
result.setTemplateMode("HTML5");
return result;
}
use of org.thymeleaf.templateresolver.ClassLoaderTemplateResolver in project thymeleaf-tests by thymeleaf.
the class ParsingDecoupled01Test method testParsingDecoupled.
private static void testParsingDecoupled(final String decoupledTemplate, final TemplateMode templateMode, final String expectedResult) throws Exception {
final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
templateResolver.setPrefix("templateparser/markup/");
templateResolver.setSuffix(templateMode == TemplateMode.HTML ? ".html" : ".xml");
templateResolver.setTemplateMode(templateMode);
final TemplateEngine templateEngine = new TemplateEngine();
templateEngine.setTemplateResolver(templateResolver);
// We only to this in order to initialize the engine
templateEngine.process("parsingdecoupled", new Context());
final IEngineConfiguration configuration = templateEngine.getConfiguration();
final TemplateResolution templateResolution = templateResolver.resolveTemplate(configuration, null, decoupledTemplate, null);
final ITemplateResource templateResource = templateResolution.getTemplateResource();
final DecoupledTemplateLogic decoupledTemplateLogic = DecoupledTemplateLogicUtils.computeDecoupledTemplateLogic(configuration, null, decoupledTemplate, null, templateResource, templateMode, (templateMode == TemplateMode.HTML ? htmlParser : xmlParser));
Assert.assertEquals(expectedResult, decoupledTemplateLogic.toString());
}
use of org.thymeleaf.templateresolver.ClassLoaderTemplateResolver in project thymeleaf-tests by thymeleaf.
the class OfflineTest method testOffline01.
@Test
public void testOffline01() throws Exception {
final Context ctx = new Context();
ctx.setVariable("one", "This is one");
final TemplateEngine templateEngine = new TemplateEngine();
templateEngine.setTemplateResolver(new ClassLoaderTemplateResolver());
final String result = templateEngine.process("offline/offline01.html", ctx);
final String expected = ResourceUtils.read(ClassLoaderUtils.getClassLoader(OfflineTest.class).getResourceAsStream("offline/offlinespring01-result.html"), "UTF-8", true);
Assert.assertEquals(expected, ResourceUtils.normalize(result));
}
use of org.thymeleaf.templateresolver.ClassLoaderTemplateResolver in project thymeleaf-tests by thymeleaf.
the class OfflineTest method testOfflineSpring01.
@Test
public void testOfflineSpring01() throws Exception {
final Context ctx = new Context();
ctx.setVariable("one", "This is one");
final SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(new ClassLoaderTemplateResolver());
final String result = templateEngine.process("offline/offlinespring01.html", ctx);
final String expected = ResourceUtils.read(ClassLoaderUtils.getClassLoader(OfflineTest.class).getResourceAsStream("offline/offlinespring01-result.html"), "UTF-8", true);
Assert.assertEquals(expected, ResourceUtils.normalize(result));
}
use of org.thymeleaf.templateresolver.ClassLoaderTemplateResolver in project thymeleaf-tests by thymeleaf.
the class Parsing03Test method testParsing.
@Test
public void testParsing() throws Exception {
final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
templateResolver.setTemplateMode("HTML5");
templateResolver.setCharacterEncoding("UTF-16");
final TemplateEngine templateEngine = new TemplateEngine();
templateEngine.setTemplateResolver(templateResolver);
final String result = templateEngine.process("parsing/parsingtest03.bulk", new Context());
final String expected = ResourceUtils.read(ClassLoaderUtils.getClassLoader(Parsing03Test.class).getResourceAsStream("parsing/parsingtest03-result.bulk"), "ISO-8859-1", true);
Assert.assertEquals(expected, ResourceUtils.normalize(result));
}
Aggregations