- All Superinterfaces:
MessageEncoder
Template engine renderer. This class renderer instances of
ModelAndView
objects. Template
engine rendering is done by checking view name and supported file extensions()
.- Since:
- 2.0.0
- Author:
- edgar
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Default template path.static final String
Name of application property that defines the template path.Fields inherited from interface io.jooby.MessageEncoder
TO_STRING
-
Method Summary
Modifier and TypeMethodDescriptiondefault byte[]
MessageEncoder a value into a byte array ornull
if given object isn't supported it.Number of file extensions supported by the template engine.static String
normalizePath
(String templatesPath) Normalize a template path by removing the leading `/` when present.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.
-
Field Details
-
TEMPLATE_PATH
Name of application property that defines the template path.- See Also:
-
PATH
Default template path.- See Also:
-
-
Method Details
-
render
Render a model and view instance as String.- Parameters:
ctx
- Web context.modelAndView
- Model and view.- Returns:
- Rendered template.
- Throws:
Exception
- If something goes wrong.
-
encode
Description copied from interface:MessageEncoder
MessageEncoder a value into a byte array ornull
if given object isn't supported it.- Specified by:
encode
in interfaceMessageEncoder
- Parameters:
ctx
- Web context.value
- Value to render.- Returns:
- Value as byte array or
null
if given object isn't supported it. - Throws:
Exception
- If something goes wrong.
-
supports
True if the template engine is able to render the given view. This method checks if the view name matches one of theextensions()
.- Parameters:
modelAndView
- View to check.- Returns:
- True when view is supported.
-
extensions
Number of file extensions supported by the template engine. Default is.html
.- Returns:
- Number of file extensions supported by the template engine. Default is
.html
.
-
normalizePath
Normalize a template path by removing the leading `/` when present.- Parameters:
templatesPath
- Template path.- Returns:
- Normalized path.
-