Search in sources :

Example 41 with ClassLoaderTemplateResolver

use of org.thymeleaf.templateresolver.ClassLoaderTemplateResolver in project zhcet-web by zhcet-amu.

the class TemplateConfig method jsTemplateResolver.

private ITemplateResolver jsTemplateResolver() {
    final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
    templateResolver.setOrder(3);
    templateResolver.setResolvablePatterns(Collections.singleton("js/*"));
    templateResolver.setPrefix(TEMPLATE_PREFIX);
    templateResolver.setSuffix(".js");
    templateResolver.setTemplateMode(TemplateMode.JAVASCRIPT);
    templateResolver.setCharacterEncoding(TEMPLATE_ENCODING);
    templateResolver.setCacheable(thymeleafProperties.isCache());
    return templateResolver;
}
Also used : ClassLoaderTemplateResolver(org.thymeleaf.templateresolver.ClassLoaderTemplateResolver)

Example 42 with ClassLoaderTemplateResolver

use of org.thymeleaf.templateresolver.ClassLoaderTemplateResolver in project zhcet-web by zhcet-amu.

the class TemplateConfig method textTemplateResolver.

private ITemplateResolver textTemplateResolver() {
    final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
    templateResolver.setOrder(1);
    templateResolver.setResolvablePatterns(Collections.singleton("text/*"));
    templateResolver.setPrefix(TEMPLATE_PREFIX);
    templateResolver.setSuffix(".txt");
    templateResolver.setTemplateMode(TemplateMode.TEXT);
    templateResolver.setCharacterEncoding(TEMPLATE_ENCODING);
    templateResolver.setCacheable(thymeleafProperties.isCache());
    return templateResolver;
}
Also used : ClassLoaderTemplateResolver(org.thymeleaf.templateresolver.ClassLoaderTemplateResolver)

Example 43 with ClassLoaderTemplateResolver

use of org.thymeleaf.templateresolver.ClassLoaderTemplateResolver in project stdlib by petergeneric.

the class GuiceCoreTemplater method createEngine.

private static TemplateEngine createEngine() {
    ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
    resolver.setTemplateMode("HTML5");
    resolver.setCacheTTLMs(60 * 1000L);
    resolver.setCacheable(true);
    TemplateEngine engine = new TemplateEngine();
    engine.setTemplateResolver(resolver);
    return engine;
}
Also used : ClassLoaderTemplateResolver(org.thymeleaf.templateresolver.ClassLoaderTemplateResolver) TemplateEngine(org.thymeleaf.TemplateEngine)

Example 44 with ClassLoaderTemplateResolver

use of org.thymeleaf.templateresolver.ClassLoaderTemplateResolver in project nutzboot by nutzam.

the class ThymeleafView method initializeTemplateResolver.

private ITemplateResolver initializeTemplateResolver(ClassLoader classLoader, NutMap prop) {
    ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver(classLoader);
    templateResolver.setTemplateMode(prop.getString("mode", "HTML"));
    templateResolver.setPrefix(prop.getString("prefix", "template/"));
    templateResolver.setSuffix(prop.getString("suffix", ".html"));
    templateResolver.setCharacterEncoding(prop.getString("encoding", "UTF-8"));
    templateResolver.setCacheable(prop.getBoolean("cache", true));
    templateResolver.setCacheTTLMs(prop.getLong("cacheTTLMs", 3600000L));
    return templateResolver;
}
Also used : ClassLoaderTemplateResolver(org.thymeleaf.templateresolver.ClassLoaderTemplateResolver)

Example 45 with ClassLoaderTemplateResolver

use of org.thymeleaf.templateresolver.ClassLoaderTemplateResolver in project ff4j by ff4j.

the class FF4jServlet method initializeTemplateEngine.

/**
 * Initialize Thymeleaf.
 */
private void initializeTemplateEngine() {
    ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
    templateResolver.setTemplateMode("XHTML");
    templateResolver.setPrefix("views/view-");
    templateResolver.setSuffix(".html");
    templateResolver.setCacheTTLMs(3600000L);
    templateEngine = new TemplateEngine();
    templateEngine.setTemplateResolver(templateResolver);
    templateEngine.addMessageResolver(new CustomMessageResolver());
    LOGGER.info("Thymeleaf has been initialized");
}
Also used : ClassLoaderTemplateResolver(org.thymeleaf.templateresolver.ClassLoaderTemplateResolver) TemplateEngine(org.thymeleaf.TemplateEngine) CustomMessageResolver(org.ff4j.web.thymeleaf.CustomMessageResolver)

Aggregations

ClassLoaderTemplateResolver (org.thymeleaf.templateresolver.ClassLoaderTemplateResolver)50 Test (org.junit.Test)18 SpringTemplateEngine (org.thymeleaf.spring5.SpringTemplateEngine)17 ArrayList (java.util.ArrayList)13 TemplateEngine (org.thymeleaf.TemplateEngine)13 Context (org.thymeleaf.context.Context)12 ITemplateResolver (org.thymeleaf.templateresolver.ITemplateResolver)12 FileTemplateResolver (org.thymeleaf.templateresolver.FileTemplateResolver)8 DefaultTemplateResolver (org.thymeleaf.templateresolver.DefaultTemplateResolver)4 Bean (org.springframework.context.annotation.Bean)3 HashMap (java.util.HashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2 IExpressionContext (org.thymeleaf.context.IExpressionContext)2 StandardLinkBuilder (org.thymeleaf.linkbuilder.StandardLinkBuilder)2 SpringWebFluxTemplateEngine (org.thymeleaf.spring5.SpringWebFluxTemplateEngine)2 AbstractConfigurableTemplateResolver (org.thymeleaf.templateresolver.AbstractConfigurableTemplateResolver)2 FileOutputStream (java.io.FileOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1