Thymeleaf template related functions.
Example
var thymeleafLib = require('/lib/xp/thymeleaf');
Methods
(static) render(view, model, optionsopt) → {string}
This function renders a view using thymeleaf.
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
view |
Location of the view. Use |
||||||||||||
model |
object | Model that is passed to the view. |
|||||||||||
options |
object |
<optional> |
Rendering options (optional). Properties
|
Returns:
The rendered output.
- Type
- string
Examples
var view = resolve('view/fruit.html');
var model = {
fruits: [
{
name: 'Apple',
color: 'Red'
},
{
name: 'Pear',
color: 'Green'
}
]
};
var result = thymeleafLib.render(view, model);
// Render using options.
result = thymeleafLib.render(view, model, {
mode: 'html'
});