ThymeLeaf中的条件文本:如何以纯文本形式进行?

Cyr*_*ghe 3 if-statement plaintext thymeleaf

我理解如何:如果适用于html模板,但我没有找到任何关于如何做到这一点的线索当你期望纯文本(用例:纯文本电子邮件模板).

到目前为止我试过:

<html xmlns:th="http://www.thymeleaf.org" th:inline="text" th:remove="tag">
  Dear [[${contact.firstname}]] [[${contact.lastname}]],
  An alert was triggered at location:  [[${account.address}]] 
  <span th:if=\"${videoLink}\">To view your security camera recordings, please click on [[${videoLink]]</span>
</html>
Run Code Online (Sandbox Code Playgroud)

它有效...但结果包含标签.我知道我做错了什么?

谢谢,西里尔

snw*_*snw 7

Thymeleaf 2.1有一个th:block标签,它基本上是属性的容器.您的条件文本可以这样完成:

<th:block th:if="${videoLink}">To view your...</th:block>
Run Code Online (Sandbox Code Playgroud)