use of org.thymeleaf.TemplateEngine in project java-docs-samples by GoogleCloudPlatform.
the class GaeInfoServlet method init.
@Override
public void init() {
// Setup ThymeLeaf
ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(this.getServletContext());
templateResolver.setPrefix("/WEB-INF/templates/");
templateResolver.setSuffix(".html");
// TTL=20m
templateResolver.setCacheTTLMs(Long.valueOf(1200000L));
// Cache is set to true by default. Set to false if you want templates to
// be automatically updated when modified.
templateResolver.setCacheable(true);
templateEngine = new TemplateEngine();
templateEngine.setTemplateResolver(templateResolver);
}
use of org.thymeleaf.TemplateEngine in project stdlib by petergeneric.
the class GuiceCoreTemplater method createEngine.
private static TemplateEngine createEngine() {
ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
resolver.setTemplateMode("HTML5");
resolver.setCacheTTLMs(60 * 1000L);
resolver.setCacheable(true);
TemplateEngine engine = new TemplateEngine();
engine.setTemplateResolver(resolver);
return engine;
}
use of org.thymeleaf.TemplateEngine in project stdlib by petergeneric.
the class GuiceCoreTemplater method getOrCreateEngine.
private TemplateEngine getOrCreateEngine() {
TemplateEngine engine = this.engine.get();
// Lazy-create the engine
if (engine == null) {
// Build and cache a new templater (previous instance must have been garbage collected)
engine = createEngine();
this.engine = new WeakReference<>(engine);
}
return engine;
}
use of org.thymeleaf.TemplateEngine in project stdlib by petergeneric.
the class ThymeleafModule method getTemplateEngine.
@Provides
@Singleton
public TemplateEngine getTemplateEngine(ITemplateResolver resolver) {
TemplateEngine engine = new TemplateEngine();
engine.setTemplateResolver(resolver);
return engine;
}
use of org.thymeleaf.TemplateEngine in project ff4j by ff4j.
the class FF4jServlet method initializeTemplateEngine.
/**
* Initialize Thymeleaf.
*/
private void initializeTemplateEngine() {
ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
templateResolver.setTemplateMode("XHTML");
templateResolver.setPrefix("views/view-");
templateResolver.setSuffix(".html");
templateResolver.setCacheTTLMs(3600000L);
templateEngine = new TemplateEngine();
templateEngine.setTemplateResolver(templateResolver);
templateEngine.addMessageResolver(new CustomMessageResolver());
LOGGER.info("Thymeleaf has been initialized");
}
Aggregations