简体   繁体   English

百里香叶的可读性

[英]Readability of thymeleaf

I'm used to writing templates like this: 我习惯于编写这样的模板:

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

This seems much more readable for me, in that I can see the variables outside of the tags themselves. 对于我来说,这似乎更具可读性,因为我可以看到标签本身之外的变量。 Currently in thymeleaf, I would need to do: 目前在百里香,我需要做:

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

Or: 要么:

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

Is there a way to enter in the variable like I have at the top? 有没有办法像我在顶部那样输入变量?

Sure, you can use expression inlining for this. 当然,您可以为此使用表达式内联

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

In the documentation I linked, it does have a discussion of using expression inlining vs natural templating. 在我链接的文档中,确实讨论了使用表达式内联与自然模板的关系。 I personally prefer natural templating in most cases. 在大多数情况下,我个人更喜欢自然模板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM