thymeleaf

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 resolve(..) to resolve a view.

model object

Model that is passed to the view.

options object <optional>

Rendering options (optional).

Properties
Name Type Attributes Default Description
mode string <optional>
HTML

Rendering mode. Valid options are: HTML, XML, TEXT, JAVASCRIPT, CSS and RAW.

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'
});