use of org.thymeleaf.TemplateEngine in project spring-boot by spring-projects.
the class ThymeleafAutoConfigurationTests method useJava8TimeDialect.
@Test
public void useJava8TimeDialect() throws Exception {
this.context.register(ThymeleafAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
TemplateEngine engine = this.context.getBean(TemplateEngine.class);
Context attrs = new Context(Locale.UK);
String result = engine.process("java8time-dialect", attrs);
assertThat(result).isEqualTo("<html><body>2015-11-24</body></html>");
}
use of org.thymeleaf.TemplateEngine in project spring-boot by spring-projects.
the class ThymeleafAutoConfigurationTests method createFromConfigClass.
@Test
public void createFromConfigClass() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, "spring.thymeleaf.mode:XHTML", "spring.thymeleaf.suffix:");
this.context.register(ThymeleafAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
TemplateEngine engine = this.context.getBean(TemplateEngine.class);
Context attrs = new Context(Locale.UK, Collections.singletonMap("foo", "bar"));
String result = engine.process("template.txt", attrs);
assertThat(result).isEqualTo("<html>bar</html>");
}
use of org.thymeleaf.TemplateEngine in project spring-boot by spring-projects.
the class ThymeleafAutoConfigurationTests method useDataDialect.
@Test
public void useDataDialect() throws Exception {
this.context.register(ThymeleafAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
TemplateEngine engine = this.context.getBean(TemplateEngine.class);
Context attrs = new Context(Locale.UK, Collections.singletonMap("foo", "bar"));
String result = engine.process("data-dialect", attrs);
assertThat(result).isEqualTo("<html><body data-foo=\"bar\"></body></html>");
}
use of org.thymeleaf.TemplateEngine in project spring-boot by spring-projects.
the class ThymeleafAutoConfigurationTests method renderTemplate.
@Test
public void renderTemplate() throws Exception {
this.context.register(ThymeleafAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
TemplateEngine engine = this.context.getBean(TemplateEngine.class);
Context attrs = new Context(Locale.UK, Collections.singletonMap("foo", "bar"));
String result = engine.process("home", attrs);
assertThat(result).isEqualTo("<html><body>bar</body></html>");
}
use of org.thymeleaf.TemplateEngine in project ratpack by ratpack.
the class ThymeleafModule method provideTemplateEngine.
@Provides
@Singleton
TemplateEngine provideTemplateEngine(ITemplateResolver templateResolver, ICacheManager cacheManager, Set<IDialect> dialects) {
final TemplateEngine templateEngine = new TemplateEngine();
templateEngine.setTemplateResolver(templateResolver);
templateEngine.setCacheManager(cacheManager);
dialects.stream().forEach(templateEngine::addDialect);
return templateEngine;
}
Aggregations