Java Code Examples for org.thymeleaf.spring4.SpringTemplateEngine#addTemplateResolver()
The following examples show how to use
org.thymeleaf.spring4.SpringTemplateEngine#addTemplateResolver() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpringMailTestConfiguration.java From konker-platform with Apache License 2.0 | 6 votes |
@Bean public SpringTemplateEngine templateEngine() { SpringTemplateEngine mock = spy(SpringTemplateEngine.class); final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver(); templateResolver.setOrder(2); templateResolver.setResolvablePatterns(Collections.singleton("html/*")); templateResolver.setPrefix("/mail/"); templateResolver.setSuffix(".html"); templateResolver.setTemplateMode(TemplateMode.HTML); templateResolver.setCharacterEncoding("UTF-8"); templateResolver.setCacheable(false); mock.addTemplateResolver(templateResolver); final ClassLoaderTemplateResolver templateResolverTxt = new ClassLoaderTemplateResolver(); templateResolverTxt.setOrder(1); templateResolverTxt.setResolvablePatterns(Collections.singleton("text/*")); templateResolverTxt.setPrefix("/mail/"); templateResolverTxt.setSuffix(".txt"); templateResolverTxt.setTemplateMode(TemplateMode.TEXT); templateResolverTxt.setCharacterEncoding("UTF-8"); templateResolverTxt.setCacheable(false); mock.addTemplateResolver(templateResolverTxt); return mock; }
Example 2
Source File: SpringMailConfig.java From konker-platform with Apache License 2.0 | 5 votes |
@Bean public SpringTemplateEngine emailTemplateEngine(MessageSource messageSource) { final SpringTemplateEngine templateEngine = new SpringTemplateEngine(); templateEngine.addTemplateResolver(textTemplateResolver()); templateEngine.addTemplateResolver(htmlTemplateResolver()); templateEngine.addTemplateResolver(stringTemplateResolver()); templateEngine.setTemplateEngineMessageSource(messageSource); return templateEngine; }