Package io.micronaut.views.thymeleaf
Class ThymeleafViewsRenderer<T>
java.lang.Object
io.micronaut.views.thymeleaf.ThymeleafViewsRenderer<T>
- Type Parameters:
T
- The model type
- All Implemented Interfaces:
io.micronaut.core.order.Ordered
,ViewsRenderer<T,
io.micronaut.http.HttpRequest<?>>
@Singleton
@Requires(classes={io.micronaut.http.HttpRequest.class,io.micronaut.http.server.util.locale.HttpLocaleResolver.class})
public class ThymeleafViewsRenderer<T>
extends Object
implements ViewsRenderer<T,io.micronaut.http.HttpRequest<?>>
Renders templates Thymeleaf Java template engine.
- Since:
- 1.0
- Author:
- Sergio del Amo, graemerocher
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final org.thymeleaf.TemplateEngine
protected final io.micronaut.http.server.util.locale.HttpLocaleResolver
protected io.micronaut.core.io.ResourceLoader
protected final org.thymeleaf.templateresolver.AbstractConfigurableTemplateResolver
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionThymeleafViewsRenderer
(org.thymeleaf.templateresolver.AbstractConfigurableTemplateResolver templateResolver, org.thymeleaf.TemplateEngine templateEngine, io.micronaut.core.io.scan.ClassPathResourceLoader resourceLoader, io.micronaut.http.server.util.locale.HttpLocaleResolver httpLocaleResolver) -
Method Summary
Modifier and TypeMethodDescriptionboolean
@NonNull io.micronaut.core.io.Writable
void
render
(String viewName, Set<String> fragmentSelectors, org.thymeleaf.context.IContext context, Writer writer) Passes the arguments as is toTemplateEngine.process(String, IContext, Writer)
.void
Deprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.order.Ordered
getOrder
-
Field Details
-
templateResolver
protected final org.thymeleaf.templateresolver.AbstractConfigurableTemplateResolver templateResolver -
engine
protected final org.thymeleaf.TemplateEngine engine -
httpLocaleResolver
protected final io.micronaut.http.server.util.locale.HttpLocaleResolver httpLocaleResolver -
resourceLoader
protected io.micronaut.core.io.ResourceLoader resourceLoader
-
-
Constructor Details
-
ThymeleafViewsRenderer
public ThymeleafViewsRenderer(org.thymeleaf.templateresolver.AbstractConfigurableTemplateResolver templateResolver, org.thymeleaf.TemplateEngine templateEngine, io.micronaut.core.io.scan.ClassPathResourceLoader resourceLoader, io.micronaut.http.server.util.locale.HttpLocaleResolver httpLocaleResolver) - Parameters:
templateResolver
- The template resolvertemplateEngine
- The template engineresourceLoader
- The resource loaderhttpLocaleResolver
- The locale resolver
-
-
Method Details
-
render
@NonNull public @NonNull io.micronaut.core.io.Writable render(@NonNull @NonNull String viewName, @Nullable T data, @Nullable @Nullable io.micronaut.http.HttpRequest<?> request) - Specified by:
render
in interfaceViewsRenderer<T,
io.micronaut.http.HttpRequest<?>> - Parameters:
viewName
- view name to be rendereddata
- response body to render it with a viewrequest
- HTTP request- Returns:
- A writable where the view will be written to.
-
render
public void render(String viewName, Set<String> fragmentSelectors, org.thymeleaf.context.IContext context, Writer writer) Passes the arguments as is toTemplateEngine.process(String, IContext, Writer)
.- Parameters:
viewName
- The view namefragmentSelectors
- Fragment selectorscontext
- The contextwriter
- The writer
-
render
@Deprecated(forRemoval=true, since="5.2.0") public void render(String viewName, org.thymeleaf.context.IContext context, Writer writer) Deprecated, for removal: This API element is subject to removal in a future version.Userender(String, Set, IContext, Writer)
instead.Passes the arguments as is toTemplateEngine.process(String, IContext, Writer)
.- Parameters:
viewName
- The view namecontext
- The contextwriter
- The writer
-
exists
- Specified by:
exists
in interfaceViewsRenderer<T,
io.micronaut.http.HttpRequest<?>> - Parameters:
viewName
- view name to be rendered- Returns:
- true if a template can be found for the supplied view name.
-
render(String, Set, IContext, Writer)
instead.