Как вставить HTML из JS функции в th:text в Thymeleaf?

Я хочу показывать рейтинг в виде звездочек, рейтинг ( integer ) получаю из employee.getUser().getAvgGrade(), мне нужно его значение передать в функцию stars(), она возвращает HTML код. А его уже вставить в th:text.

Вот моя таблица:

       <table>
            <thead>
            <tr>
                <th>Name</th>
                <th>Rating</th>
                <th>Schedule</th>
            </tr>
            </thead>
           <tbody>
    <tr th:each="employee:${employees}">

        <td th:text="${employee.getUser().getFullName()}"></td>
        <td th:text="${employee.getUser().getAvgGrade()}"></td>
        <td th:text="${employee.getTimeBegin() + ' - ' + employee.getTimeEnd()}"></td>

    </tr>
    </tbody>
        </table>

Вот JS функция, которая возвращает HTML

  function star(rate) {
    var starHTML = '';
    var rate = parseInt(rate);
    var increment = 0;
    var max = 5;

    while(increment < rate) {
        starHTML += '<i class="material-icons orange">grade</i>';
        increment++;
    }

    while(max > rate) {
        starHTML += '<i class="material-icons gray">grade</i>';
        max--;
    }
    return starHTML;
};

Ну и CSS для звездочек

<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
  rel="stylesheet">

Резюмируя, я просто не знаю, как вызвать метод и вставить результат выполнения метода в th:text, чтобы ячейка таблицы отображала HTML, который возвращает метод.


Ответы (0 шт):