Search in sources :

Example 1 with TemplateConfiguration

use of groovy.text.markup.TemplateConfiguration in project ratpack by ratpack.

the class MarkupTemplateModule method provideTemplateEngine.

@SuppressWarnings("UnusedDeclaration")
@Provides
@Singleton
MarkupTemplateEngine provideTemplateEngine(ServerConfig serverConfig, Config config) {
    ClassLoader parent = Thread.currentThread().getContextClassLoader();
    TemplateConfiguration effectiveConfiguration = new TemplateConfiguration(config);
    // not copied by constructor
    effectiveConfiguration.setCacheTemplates(config.isCacheTemplates());
    Path templatesDir = serverConfig.getBaseDir().file(config.getTemplatesDirectory());
    return new MarkupTemplateEngine(parent, effectiveConfiguration, new CachingTemplateResolver(templatesDir));
}
Also used : Path(java.nio.file.Path) CachingTemplateResolver(ratpack.groovy.template.internal.CachingTemplateResolver) TemplateConfiguration(groovy.text.markup.TemplateConfiguration) MarkupTemplateEngine(groovy.text.markup.MarkupTemplateEngine) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 2 with TemplateConfiguration

use of groovy.text.markup.TemplateConfiguration in project spring-framework by spring-projects.

the class GroovyMarkupConfigurerTests method customTemplateConfiguration.

@Test
public void customTemplateConfiguration() throws Exception {
    this.configurer.setApplicationContext(this.applicationContext);
    this.configurer.setCacheTemplates(false);
    this.configurer.afterPropertiesSet();
    TemplateEngine engine = this.configurer.getTemplateEngine();
    assertThat(engine).isNotNull();
    assertThat(engine.getClass()).isEqualTo(MarkupTemplateEngine.class);
    MarkupTemplateEngine markupEngine = (MarkupTemplateEngine) engine;
    TemplateConfiguration configuration = markupEngine.getTemplateConfiguration();
    assertThat(configuration).isNotNull();
    assertThat(configuration.isCacheTemplates()).isFalse();
}
Also used : MarkupTemplateEngine(groovy.text.markup.MarkupTemplateEngine) TemplateEngine(groovy.text.TemplateEngine) TemplateConfiguration(groovy.text.markup.TemplateConfiguration) MarkupTemplateEngine(groovy.text.markup.MarkupTemplateEngine) Test(org.junit.jupiter.api.Test)

Example 3 with TemplateConfiguration

use of groovy.text.markup.TemplateConfiguration in project spring-framework by spring-projects.

the class GroovyMarkupConfigurerTests method defaultTemplateEngine.

@Test
public void defaultTemplateEngine() throws Exception {
    this.configurer.setApplicationContext(this.applicationContext);
    this.configurer.afterPropertiesSet();
    TemplateEngine engine = this.configurer.getTemplateEngine();
    assertThat(engine).isNotNull();
    assertThat(engine.getClass()).isEqualTo(MarkupTemplateEngine.class);
    MarkupTemplateEngine markupEngine = (MarkupTemplateEngine) engine;
    TemplateConfiguration configuration = markupEngine.getTemplateConfiguration();
    assertThat(configuration).isNotNull();
    assertThat(configuration.getClass()).isEqualTo(GroovyMarkupConfigurer.class);
}
Also used : MarkupTemplateEngine(groovy.text.markup.MarkupTemplateEngine) TemplateEngine(groovy.text.TemplateEngine) TemplateConfiguration(groovy.text.markup.TemplateConfiguration) MarkupTemplateEngine(groovy.text.markup.MarkupTemplateEngine) Test(org.junit.jupiter.api.Test)

Aggregations

MarkupTemplateEngine (groovy.text.markup.MarkupTemplateEngine)3 TemplateConfiguration (groovy.text.markup.TemplateConfiguration)3 TemplateEngine (groovy.text.TemplateEngine)2 Test (org.junit.jupiter.api.Test)2 Provides (com.google.inject.Provides)1 Path (java.nio.file.Path)1 Singleton (javax.inject.Singleton)1 CachingTemplateResolver (ratpack.groovy.template.internal.CachingTemplateResolver)1