Search in sources :

Example 1 with CachingTemplateResolver

use of ratpack.groovy.template.internal.CachingTemplateResolver 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)

Aggregations

Provides (com.google.inject.Provides)1 MarkupTemplateEngine (groovy.text.markup.MarkupTemplateEngine)1 TemplateConfiguration (groovy.text.markup.TemplateConfiguration)1 Path (java.nio.file.Path)1 Singleton (javax.inject.Singleton)1 CachingTemplateResolver (ratpack.groovy.template.internal.CachingTemplateResolver)1