【发布时间】:2018-07-02 21:06:07
【问题描述】:
我习惯这样写模板:
<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>
有没有办法像我在顶部那样输入变量?
【问题讨论】:
-
Thymeleaf 的重点是模板是有效且可呈现的 HTML,这使得 1) 样式、2) 验证、3) 格式化更容易。个人我认为 Thymlead 比混合多种不同的语言更具可读性。现在 - 问题 - “我认为”意味着这是基于意见的,所以又跑题了。
-
P.S. worth reading
-
如果您想这样,请使用 JSP 和标准标签库。此时您正在订购味道应该像鱼的牛肉。