hasRole check doesnt work with th:replace
Seems like the correct syntax for this should look like:
<div th:replace="${#authorization.expression('hasRole(''ROLE'')')} ? ~{fragments/first :: content(content=${content})} : ~{fragments/second :: content(content=${content})}"></div>
Even further, this syntax worked for me as well:
<div th:replace="~{${'fragments/' + (#authorization.expression('hasRole(''ROLE'')') ? 'first' : 'second')} :: content(content=${content})}"></div>