@Bean public TemplateEngine mailNotifierTemplateEngine() { SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver(); resolver.setApplicationContext(this.applicationContext); resolver.setTemplateMode(TemplateMode.HTML); resolver.setCharacterEncoding(StandardCharsets.UTF_8.name()); SpringTemplateEngine templateEngine = new SpringTemplateEngine(); templateEngine.addTemplateResolver(resolver); return templateEngine; } }
@Component public class ThymeLeafSetup implements InitializingBean { @Autowired private SpringTemplateEngine templateEngine; @Override public void afterPropertiesSet() throws Exception { templateEngine.addDialect(new HoursDialect()); } }
static DataDrivenFluxStep forHead(final StreamThrottledTemplateProcessor throttledProcessor) { return new DataDrivenFluxStep(throttledProcessor, null, DATA_DRIVEN_PHASE_HEAD); }
@Bean public ISpringWebFluxTemplateEngine thymeleafTemplateEngine() { // We override here the SpringTemplateEngine instance that would otherwise be // instantiated by // Spring Boot because we want to apply the SpringWebFlux-specific context // factory, link builder... final SpringWebFluxTemplateEngine templateEngine = new SpringWebFluxTemplateEngine(); templateEngine.setTemplateResolver(thymeleafTemplateResolver()); return templateEngine; }
templateResolver.setTemplateMode(TemplateMode.TEXT); SpringStandardDialect dialect = new SpringStandardDialect(); dialect.setEnableSpringELCompiler(true); SpringTemplateEngine engine = new SpringTemplateEngine(); engine.setDialect(dialect); engine.setEnableSpringELCompiler(true); engine.setTemplateResolver(templateResolver); String body = engine.process(theDetails.getBodyTemplate(), context); String subject = engine.process(theDetails.getSubjectTemplate(), context);
() -> new StreamThrottledTemplateProcessor( processThrottled(templateName, markupSelectors, context), null, null, 0L, false), throttledProcessor.startChunk(); "\"{}\", CHUNK {}) FOR TEMPLATE \"{}\" WITH LOCALE {}", new Object[]{ TemplateEngine.threadIndex(), throttledProcessor.getProcessorIdentifier(), throttledProcessor.getProcessorIdentifier(), Integer.valueOf(throttledProcessor.getChunkCount()), LoggingUtils.loggifyTemplateName(templateName), context.getLocale()}); try { bytesProduced = throttledProcessor.process(responseMaxChunkSizeBytes, buffer.asOutputStream(), charset); } catch (final Throwable t) { emitter.error(t); "\"{}\", CHUNK {}) FOR TEMPLATE \"{}\" WITH LOCALE {}. PRODUCED {} BYTES", new Object[]{ TemplateEngine.threadIndex(), throttledProcessor.getProcessorIdentifier(), throttledProcessor.getProcessorIdentifier(), Integer.valueOf(throttledProcessor.getChunkCount()), LoggingUtils.loggifyTemplateName(templateName), context.getLocale(), Integer.valueOf(bytesProduced)}); if (throttledProcessor.isFinished()) { "\"{}\") FOR TEMPLATE \"{}\" WITH LOCALE {}. PRODUCED A TOTAL OF {} BYTES IN {} CHUNKS", new Object[]{ TemplateEngine.threadIndex(), throttledProcessor.getProcessorIdentifier(), throttledProcessor.getProcessorIdentifier(),
@Override public void clearViewsCache() { ThymeleafViewResolver viewResolver = applicationContext.getBean(ThymeleafViewResolver.class); viewResolver.clearCache(); viewResolver.getTemplateEngine().getConfiguration().getTemplateManager().clearCaches(); } }
final String dataDriverVariableName = findDataDriverInModel(context); if (dataDriverVariableName != null) { return createDataDrivenStream( template, markupSelectors, context, dataDriverVariableName, bufferFactory, charset, chunkSizeBytes, sse); return createFullStream(template, markupSelectors, context, bufferFactory, charset); return createChunkedStream( template, markupSelectors, context, bufferFactory, charset, responseMaxChunkSizeBytes);
public SpringWebFluxTemplateEngine() { super(); // In Spring WebFlux environments, we will need to use a special context factory in order to // use an environment-tailored implementation of IEngineContext. this.setEngineContextFactory(new SpringWebFluxEngineContextFactory()); // In Spring WebFlux environments, we will need to use a special link builder able to adapt // the creation of URLs as a result of @{...} expressions in a way that makes sense in this // environment. this.setLinkBuilder(new SpringWebFluxLinkBuilder()); }
final Set<IDialect> dialects = getDialects(); for (final IDialect dialect : dialects) { if (dialect instanceof SpringStandardDialect) { ((SpringStandardDialect) dialect).setEnableSpringELCompiler(enableSpringELCompiler);
@Override protected final void initializeSpecific() { // First of all, give the opportunity to subclasses to apply their own configurations initializeSpringSpecific(); // Once the subclasses have had their opportunity, compute configurations belonging to SpringTemplateEngine super.initializeSpecific(); final MessageSource messageSource = this.templateEngineMessageSource == null ? this.messageSource : this.templateEngineMessageSource; final IMessageResolver messageResolver; if (messageSource != null) { final SpringMessageResolver springMessageResolver = new SpringMessageResolver(); springMessageResolver.setMessageSource(messageSource); messageResolver = springMessageResolver; } else { messageResolver = new StandardMessageResolver(); } super.setMessageResolver(messageResolver); }
@Autowired protected void configureThymeleafSpringTemplateEngine(SpringTemplateEngine templateEngine) { templateEngine.setEnableSpringELCompiler(true); }
private static IContext applyDataDriverWrapper( final IContext context, final String dataDriverVariableName, final DataDrivenTemplateIterator dataDrivenTemplateIterator) { // This is an IEngineContext, a very internal, low-level context implementation, so let's simply modify it if (context instanceof IEngineContext) { ((IEngineContext)context).setVariable(dataDriverVariableName, dataDrivenTemplateIterator); return context; } // Not an IEngineContext, but might still be an ISpringWebFluxContext and we don't want to lose that info if (context instanceof ISpringWebFluxContext) { return new DataDrivenSpringWebFluxContextWrapper( (ISpringWebFluxContext)context, dataDriverVariableName, dataDrivenTemplateIterator); } // Not a recognized context interface: just use a default implementation return new DataDrivenContextWrapper(context, dataDriverVariableName, dataDrivenTemplateIterator); }
final Set<IDialect> dialects = getDialects(); for (final IDialect dialect : dialects) { if (dialect instanceof SpringStandardDialect) { return ((SpringStandardDialect) dialect).getEnableSpringELCompiler();
final Set<IDialect> dialects = getDialects(); for (final IDialect dialect : dialects) { if (dialect instanceof SpringStandardDialect) { return ((SpringStandardDialect) dialect).getRenderHiddenMarkersBeforeCheckboxes();
final Set<IDialect> dialects = getDialects(); for (final IDialect dialect : dialects) { if (dialect instanceof SpringStandardDialect) { ((SpringStandardDialect) dialect).setRenderHiddenMarkersBeforeCheckboxes(renderHiddenMarkersBeforeCheckboxes);
@Bean public ISpringWebFluxTemplateEngine thymeleafTemplateEngine() { // We override here the SpringTemplateEngine instance that would otherwise be // instantiated by // Spring Boot because we want to apply the SpringWebFlux-specific context // factory, link builder... final SpringWebFluxTemplateEngine templateEngine = new SpringWebFluxTemplateEngine(); templateEngine.setTemplateResolver(thymeleafTemplateResolver()); return templateEngine; }
static DataDrivenFluxStep forBuffer(final StreamThrottledTemplateProcessor throttledProcessor, final List<Object> values) { return new DataDrivenFluxStep(throttledProcessor, values, DATA_DRIVEN_PHASE_BUFFER); }
@Bean public ISpringWebFluxTemplateEngine thymeleafTemplateEngine() { // We override here the SpringTemplateEngine instance that would otherwise be // instantiated by // Spring Boot because we want to apply the SpringWebFlux-specific context // factory, link builder... final SpringWebFluxTemplateEngine templateEngine = new SpringWebFluxTemplateEngine(); templateEngine.setTemplateResolver(thymeleafTemplateResolver()); return templateEngine; }
static DataDrivenFluxStep forTail(final StreamThrottledTemplateProcessor throttledProcessor) { return new DataDrivenFluxStep(throttledProcessor, null, DATA_DRIVEN_PHASE_TAIL); }