2017-06-29 5 views
-1

Ich habe dieses Stück Code in meiner Thymeleaf HTML-Seite, würde ich gerne wissen, ob es möglich ist, zu setzen und wenn sonst in derselben AnweisungThymeleaf HTML wenn sonst in der gleichen Zeile

<div th:if="${book.htmlIconColor != null}" > 
<i class="fa fa-exchange fa-2x" th:style="${'color:' + book.htmlIconColor + '; text-align: center;'}" aria-hidden="true"></i>      
</div> 
<div th:if="${book.htmlIconColor == null}" > 
<i class="fa fa-exchange fa-2x" aria-hidden="true"></i>      
</div> 

Antwort

2

etwas probieren wie folgt aus:

condition ? first_expression : second_expression; 

Zum Beispiel

<i class="fa fa-exchange fa-2x" aria-hidden="true" th:style="${book.htmlIconColor} ? 'color:' + ${book.htmlIconColor} + '; text-align: center;' : 'text-align: center;'"></i> 
Verwandte Themen