spring - Display a variable inside another with thymeleaf -
i have th:each loop display buttons.
<li th:id="${'button-' + row.name }" th:unless="${row.name == 'linkedin' or row.name == 'slideshow'}" class="collection-item avatar" th:each="row, rowstat: *{arbuttons}"> <img th:src="${'/images/buttons/' + row.name + '.png'}" th:alt="${row.name}" class="circle"/> <div class=" input-field col s12"> <input th:field="*{arbuttons[__${rowstat.index}__].name}" type="hidden" /> <input th:field="*{arbuttons[__${rowstat.index}__].data}" th:id="${'button-'+rowstat.index}" type="text" class="validate" /> <label th:if="${row.name == 'call'}" th:for="${'button-'+rowstat.index}" th:text="${call}"> phone number </label> <label th:if="${row.name == 'mail'}" th:for="${'button-'+rowstat.index}" th:text="${mail}"> email </label> <label th:if="${row.name == 'link'}" th:for="${'button-'+rowstat.index}" th:text="${link}"> web link </label> <label th:if="${row.name == 'video'}" th:for="${'button-'+rowstat.index}" th:text="${video}"> video </label> </div> </li>
now don't want use every time check on row.name in order display convient text there way use like
<label th:for="${'button-'+rowstat.index}" th:text="${${row.name}}"> </label>
please idea !
check out thymeleaf's preprocessing capabilities. case think
th:text="${__(${row.name})__}"
note should use double underscores , parenthesis ommited, makes more clear me
Comments
Post a Comment