簡體   English   中英

百里香葉的可讀性

[英]Readability of thymeleaf

我習慣於編寫這樣的模板:

<div class="person">
    ${name}
</div>

對於我來說,這似乎更具可讀性,因為我可以看到標簽本身之外的變量。 目前在百里香,我需要做:

<div class="person" th:text="${name}" />

要么:

<div class="person" th:text="${name}">
    ${name} // this text will be replaced and doesn't matter
</div>

有沒有辦法像我在頂部那樣輸入變量?

當然,您可以為此使用表達式內聯

<div class="person">
    [[${name}]]
</div>

在我鏈接的文檔中,確實討論了使用表達式內聯與自然模板的關系。 在大多數情況下,我個人更喜歡自然模板。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM