Search in sources :

Example 26 with SpringTemplateEngine

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

the class IridaUIWebConfig method templateEngine.

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

Example 27 with SpringTemplateEngine

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

the class MvcConfiguration method templateEngine.

/**
 * Thymeleaf needs a template engine, get a {@link SpringTemplateEngine}
 *
 * @return {@link SpringTemplateEngine}
 */
@Bean
public SpringTemplateEngine templateEngine() {
    SpringTemplateEngine engine = new SpringTemplateEngine();
    engine.setTemplateResolver(templateResolver());
    return engine;
}
Also used : SpringTemplateEngine(org.thymeleaf.spring4.SpringTemplateEngine) Bean(org.springframework.context.annotation.Bean)

Example 28 with SpringTemplateEngine

use of org.thymeleaf.spring5.SpringTemplateEngine in project spring-boot-admin by codecentric.

the class MailNotifierTest method setup.

@BeforeEach
public void setup() {
    repository = mock(InstanceRepository.class);
    when(repository.find(instance.getId())).thenReturn(Mono.just(instance));
    sender = mock(JavaMailSender.class);
    when(sender.createMimeMessage()).thenAnswer((args) -> new MimeMessage(Session.getInstance(new Properties())));
    SpringTemplateEngine templateEngine = new SpringTemplateEngine();
    ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
    resolver.setTemplateMode(TemplateMode.HTML);
    resolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
    templateEngine.addTemplateResolver(resolver);
    notifier = new MailNotifier(sender, repository, templateEngine);
    notifier.setTo(new String[] { "foo@bar.com" });
    notifier.setCc(new String[] { "bar@foo.com" });
    notifier.setFrom("SBA <no-reply@example.com>");
    notifier.setBaseUrl("http://localhost:8080");
    notifier.setTemplate("/META-INF/spring-boot-admin-server/mail/status-changed.html");
}
Also used : SpringTemplateEngine(org.thymeleaf.spring5.SpringTemplateEngine) ClassLoaderTemplateResolver(org.thymeleaf.templateresolver.ClassLoaderTemplateResolver) MimeMessage(javax.mail.internet.MimeMessage) InstanceRepository(de.codecentric.boot.admin.server.domain.entities.InstanceRepository) JavaMailSender(org.springframework.mail.javamail.JavaMailSender) Properties(java.util.Properties) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

SpringTemplateEngine (org.thymeleaf.spring5.SpringTemplateEngine)15 SpringTemplateEngine (org.thymeleaf.spring4.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