public interface TemplateEngine extends MessageEncoder
ModelAndView
objects.
Template engine rendering is done by checking view name and supported file extensions()
.Modifier and Type | Field and Description |
---|---|
static String |
PATH
Default template path.
|
static String |
TEMPLATE_PATH
Name of application property that defines the template path.
|
TO_STRING
Modifier and Type | Method and Description |
---|---|
default byte[] |
encode(Context ctx,
Object value)
MessageEncoder a value into a byte array or
null if given object isn't supported it. |
default List<String> |
extensions()
Number of file extensions supported by the template engine.
|
static String |
normalizePath(String templatesPath)
Normalize a template path by removing the leading `/` when present.
|
String |
render(Context ctx,
ModelAndView modelAndView)
Render a model and view instance as String.
|
default boolean |
supports(ModelAndView modelAndView)
True if the template engine is able to render the given view.
|
accept
static final String TEMPLATE_PATH
static final String PATH
String render(Context ctx, ModelAndView modelAndView) throws Exception
ctx
- Web context.modelAndView
- Model and view.Exception
- If something goes wrong.default byte[] encode(@Nonnull Context ctx, @Nonnull Object value) throws Exception
MessageEncoder
null
if given object isn't supported it.encode
in interface MessageEncoder
ctx
- Web context.value
- Value to render.null
if given object isn't supported it.Exception
- If something goes wrong.default boolean supports(@Nonnull ModelAndView modelAndView)
extensions()
.modelAndView
- View to check.@Nonnull default List<String> extensions()
.html
..html
.Copyright © 2020. All rights reserved.