@SuppressWarnings("UnusedDeclaration")
@Provides
@Singleton
ITemplateResolver provideTemplateResolver(LaunchConfig launchConfig) {
IResourceResolver resourceResolver = new FileSystemBindingThymeleafResourceResolver(launchConfig.getBaseDir());
TemplateResolver templateResolver = new TemplateResolver();
templateResolver.setResourceResolver(resourceResolver);
String mode = templatesMode == null ? launchConfig.getOther("thymeleaf.templatesMode", DEFAULT_TEMPLATE_MODE) : templatesMode;
templateResolver.setTemplateMode(mode);
String prefix = templatesPrefix == null ? launchConfig.getOther("thymeleaf.templatesPrefix", DEFAULT_TEMPLATE_PREFIX) : templatesPrefix;
if (!prefix.endsWith(File.separator)) {
prefix += File.separator;
}
templateResolver.setPrefix(prefix);
String suffix = templatesSuffix == null ? launchConfig.getOther("thymeleaf.templatesSuffix", DEFAULT_TEMPLATE_SUFFIX) : templatesSuffix;
if (suffix.equalsIgnoreCase("")) {
suffix = DEFAULT_TEMPLATE_SUFFIX;
}
templateResolver.setSuffix(suffix);
Integer cacheSize = getCacheSizeSetting(launchConfig);
templateResolver.setCacheable(cacheSize > 0);
// Never use TTL expiration
templateResolver.setCacheTTLMs(null);
return templateResolver;
}