Search in sources :

Example 11 with SpringTemplateEngine

use of org.thymeleaf.spring6.SpringTemplateEngine in project tutorials by eugenp.

the class ThymeleafConfiguration method templateEngine.

@Bean
public SpringTemplateEngine templateEngine() {
    SpringTemplateEngine templateEngine = new SpringTemplateEngine();
    templateEngine.setTemplateResolver(thymeleafTemplateResolver());
    return templateEngine;
}
Also used : SpringTemplateEngine(org.thymeleaf.spring4.SpringTemplateEngine) Bean(org.springframework.context.annotation.Bean)

Example 12 with SpringTemplateEngine

use of org.thymeleaf.spring6.SpringTemplateEngine in project tutorials by eugenp.

the class TestConfig method templateEngine.

@Bean
public SpringTemplateEngine templateEngine() {
    final SpringTemplateEngine templateEngine = new SpringTemplateEngine();
    templateEngine.setTemplateResolver(templateResolver());
    return templateEngine;
}
Also used : SpringTemplateEngine(org.thymeleaf.spring4.SpringTemplateEngine) Bean(org.springframework.context.annotation.Bean)

Example 13 with SpringTemplateEngine

use of org.thymeleaf.spring6.SpringTemplateEngine in project irida by phac-nml.

the class IridaApiServicesConfig method exportUploadTemplateEngine.

/*
	 * Template engine for constructing ncbi export submissions
	 */
@Bean(name = "exportUploadTemplateEngine")
public SpringTemplateEngine exportUploadTemplateEngine() {
    SpringTemplateEngine exportUploadTemplateEngine = new SpringTemplateEngine();
    ClassLoaderTemplateResolver classLoaderTemplateResolver = new ClassLoaderTemplateResolver();
    classLoaderTemplateResolver.setPrefix("/ca/corefacility/bioinformatics/irida/export/");
    classLoaderTemplateResolver.setSuffix(".xml");
    classLoaderTemplateResolver.setTemplateMode(TemplateMode.XML);
    classLoaderTemplateResolver.setCharacterEncoding("UTF-8");
    exportUploadTemplateEngine.addTemplateResolver(classLoaderTemplateResolver);
    return exportUploadTemplateEngine;
}
Also used : SpringTemplateEngine(org.thymeleaf.spring4.SpringTemplateEngine) ClassLoaderTemplateResolver(org.thymeleaf.templateresolver.ClassLoaderTemplateResolver) LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

Example 14 with SpringTemplateEngine

use of org.thymeleaf.spring6.SpringTemplateEngine in project gs-spring-security-3.2 by rwinch.

the class WebMvcConfiguration method templateEngine.

@Bean
public SpringTemplateEngine templateEngine(ClassLoaderTemplateResolver templateResolver) {
    SpringTemplateEngine templateEngine = new SpringTemplateEngine();
    templateEngine.setTemplateResolver(templateResolver);
    templateEngine.addDialect(new TilesDialect());
    return templateEngine;
}
Also used : SpringTemplateEngine(org.thymeleaf.spring4.SpringTemplateEngine) TilesDialect(org.thymeleaf.extras.tiles2.dialect.TilesDialect) Bean(org.springframework.context.annotation.Bean)

Example 15 with SpringTemplateEngine

use of org.thymeleaf.spring6.SpringTemplateEngine in project thymeleaf-tests by thymeleaf.

the class ContextSequenceTest method testContextSequenceSpring.

public void testContextSequenceSpring() throws Exception {
    final SpringTemplateEngine templateEngine = new SpringTemplateEngine();
    templateEngine.setTemplateResolver(new ClassLoaderTemplateResolver());
    final Context ctx1 = new Context();
    ctx1.setVariable("myObject", new MyObjectClass("one"));
    final Context ctx2 = new Context();
    ctx2.setVariable("myObject", new MyObjectClass("two"));
    final String result1 = ResourceUtils.normalize(templateEngine.process("context/contextSequence.html", ctx1));
    final String result2 = ResourceUtils.normalize(templateEngine.process("context/contextSequence.html", ctx2));
    final String expected1 = ResourceUtils.read(ClassLoaderUtils.getClassLoader(ContextSequenceTest.class).getResourceAsStream("context/contextSequence-result1.html"), "UTF-8", true);
    final String expected2 = ResourceUtils.read(ClassLoaderUtils.getClassLoader(ContextSequenceTest.class).getResourceAsStream("context/contextSequence-result2.html"), "UTF-8", true);
    Assert.assertEquals(expected1, result1);
    Assert.assertEquals(expected2, result2);
}
Also used : SpringTemplateEngine(org.thymeleaf.spring4.SpringTemplateEngine) ClassLoaderTemplateResolver(org.thymeleaf.templateresolver.ClassLoaderTemplateResolver)

Aggregations

SpringTemplateEngine (org.thymeleaf.spring4.SpringTemplateEngine)15 SpringTemplateEngine (org.thymeleaf.spring5.SpringTemplateEngine)13 Test (org.junit.Test)11 Bean (org.springframework.context.annotation.Bean)11 ClassLoaderTemplateResolver (org.thymeleaf.templateresolver.ClassLoaderTemplateResolver)10 ArrayList (java.util.ArrayList)7 Context (org.thymeleaf.context.Context)6 ITemplateResolver (org.thymeleaf.templateresolver.ITemplateResolver)6 DefaultTemplateResolver (org.thymeleaf.templateresolver.DefaultTemplateResolver)3 FileTemplateResolver (org.thymeleaf.templateresolver.FileTemplateResolver)3 StringTemplateResolver (org.thymeleaf.templateresolver.StringTemplateResolver)3 TemplateEngine (org.thymeleaf.TemplateEngine)2 CustomDialect (com.baeldung.dialect.CustomDialect)1 InstanceRepository (de.codecentric.boot.admin.server.domain.entities.InstanceRepository)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Properties (java.util.Properties)1