Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a message without html tag with Spring and Thymeleaf

I have some html code:

<div class="brand">
    <span class="logo"></span> Title
    <small>subtitle</small>
</div>

in tag I can display text from messages.properties (with locales) in that way (spring + thymeleaf)

<small th:text="#{small.text}" />

but I don't know how to display proper language version for Title text.

thanks for advice

like image 580
Inweo Avatar asked Mar 08 '23 18:03

Inweo


2 Answers

The easiest way to accomplish this is to use expression inlining. You can use expressions directly in your html tags, like this:

<h1>
    [[#{h1.text}]]
    <small>[[#{small.text}]]</small>
</h1>

Depending on the version of thymeleaf your are using, you might have to use the property th:inline="text", like this:

<h1 th:inline="text">
    [[#{h1.text}]]
    <small th:inline="text">[[#{small.text}]]</small>
</h1>
like image 114
Metroids Avatar answered Mar 10 '23 11:03

Metroids


You can do like that :

<div class="brand">
    <span class="logo"></span><span th:text="#{title.text}" th:remove="tag"> Title </span>
    <small th:text="#{small.text}">subtitle</small>
</div>
like image 44
Sébastien Temprado Avatar answered Mar 10 '23 10:03

Sébastien Temprado