Search in sources :

Example 1 with TemplateResolver

use of org.thymeleaf.templateresolver.TemplateResolver in project ratpack by ratpack.

the class ThymeleafModule method provideTemplateResolver.

@Provides
@Singleton
ITemplateResolver provideTemplateResolver(ServerConfig serverConfig, Config config) {
    IResourceResolver resourceResolver = new FileSystemBindingThymeleafResourceResolver(serverConfig.getBaseDir());
    TemplateResolver templateResolver = new TemplateResolver();
    templateResolver.setResourceResolver(resourceResolver);
    templateResolver.setTemplateMode(getTemplatesModeSetting(config));
    templateResolver.setPrefix(getTemplatesPrefixSetting(config));
    templateResolver.setSuffix(getTemplatesSuffixSetting(config));
    templateResolver.setCacheable(getCacheSizeSetting(config) > 0);
    // Never use TTL expiration
    templateResolver.setCacheTTLMs(null);
    return templateResolver;
}
Also used : IResourceResolver(org.thymeleaf.resourceresolver.IResourceResolver) FileSystemBindingThymeleafResourceResolver(ratpack.thymeleaf.internal.FileSystemBindingThymeleafResourceResolver) TemplateResolver(org.thymeleaf.templateresolver.TemplateResolver) ITemplateResolver(org.thymeleaf.templateresolver.ITemplateResolver) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 2 with TemplateResolver

use of org.thymeleaf.templateresolver.TemplateResolver in project mxisd by kamax-io.

the class ThymeleafConfig method getFileSystemResolver.

@Bean
public TemplateResolver getFileSystemResolver() {
    TemplateResolver resolver = new TemplateResolver();
    resolver.setPrefix("");
    resolver.setSuffix("");
    resolver.setCacheable(false);
    resolver.setOrder(1);
    resolver.setResourceResolver(new FileResourceResolver());
    return resolver;
}
Also used : TemplateResolver(org.thymeleaf.templateresolver.TemplateResolver) FileResourceResolver(org.thymeleaf.resourceresolver.FileResourceResolver) Bean(org.springframework.context.annotation.Bean)

Example 3 with TemplateResolver

use of org.thymeleaf.templateresolver.TemplateResolver in project yqq by yeycfri.

the class WebConfig method templateResolver.

@Bean
public TemplateResolver templateResolver() {
    TemplateResolver templateResolver = new ServletContextTemplateResolver();
    templateResolver.setPrefix("classpath:/templates/");
    templateResolver.setSuffix(".html");
    templateResolver.setTemplateMode("LEGACYHTML5");
    return templateResolver;
}
Also used : ServletContextTemplateResolver(org.thymeleaf.templateresolver.ServletContextTemplateResolver) TemplateResolver(org.thymeleaf.templateresolver.TemplateResolver) ServletContextTemplateResolver(org.thymeleaf.templateresolver.ServletContextTemplateResolver) Bean(org.springframework.context.annotation.Bean)

Example 4 with TemplateResolver

use of org.thymeleaf.templateresolver.TemplateResolver in project thymeleaf-tests by thymeleaf.

the class AbstractDocumentProcessingTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    this.templateEngine = new TemplateEngine();
    TemplateResolver templateResolver = new ClassLoaderTemplateResolver();
    templateResolver.setSuffix(".html");
    this.templateEngine.setTemplateResolver(templateResolver);
    this.templateEngine.initialize();
    this.context = new Context();
    XPathFactory xPathFactory = XPathFactory.newInstance();
    this.xPath = xPathFactory.newXPath();
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    this.docBuilder = factory.newDocumentBuilder();
    this.docBuilder.setEntityResolver(new EntityResolver(this.templateEngine.getConfiguration()));
}
Also used : IContext(org.thymeleaf.context.IContext) Context(org.thymeleaf.context.Context) TemplateEngine(org.thymeleaf.TemplateEngine) ClassLoaderTemplateResolver(org.thymeleaf.templateresolver.ClassLoaderTemplateResolver) XPathFactory(javax.xml.xpath.XPathFactory) ClassLoaderTemplateResolver(org.thymeleaf.templateresolver.ClassLoaderTemplateResolver) TemplateResolver(org.thymeleaf.templateresolver.TemplateResolver) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) EntityResolver(org.thymeleaf.templateparser.EntityResolver)

Aggregations

TemplateResolver (org.thymeleaf.templateresolver.TemplateResolver)4 Bean (org.springframework.context.annotation.Bean)2 Provides (com.google.inject.Provides)1 Singleton (com.google.inject.Singleton)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 XPathFactory (javax.xml.xpath.XPathFactory)1 TemplateEngine (org.thymeleaf.TemplateEngine)1 Context (org.thymeleaf.context.Context)1 IContext (org.thymeleaf.context.IContext)1 FileResourceResolver (org.thymeleaf.resourceresolver.FileResourceResolver)1 IResourceResolver (org.thymeleaf.resourceresolver.IResourceResolver)1 EntityResolver (org.thymeleaf.templateparser.EntityResolver)1 ClassLoaderTemplateResolver (org.thymeleaf.templateresolver.ClassLoaderTemplateResolver)1 ITemplateResolver (org.thymeleaf.templateresolver.ITemplateResolver)1 ServletContextTemplateResolver (org.thymeleaf.templateresolver.ServletContextTemplateResolver)1 FileSystemBindingThymeleafResourceResolver (ratpack.thymeleaf.internal.FileSystemBindingThymeleafResourceResolver)1