Beispiel aus Thymeleaf-Doku überarbeitet
authorKai Moritz <kai@juplo.de>
Wed, 24 Apr 2019 15:56:36 +0000 (17:56 +0200)
committerKai Moritz <kai@juplo.de>
Sun, 5 May 2019 16:28:49 +0000 (18:28 +0200)
Mit Syntax aus "Advanced conditional insertion of fragments" so aufgemotzt,
dass es nicht an fehlenden Variablen/Fragmenten scheitert.

dist/templates/example/layout.html

index 82bd254..a5cad60 100644 (file)
@@ -1,11 +1,11 @@
 <!DOCTYPE html>
 <html th:fragment="layout (title, content)" xmlns:th="http://www.thymeleaf.org">
 <head>
 <!DOCTYPE html>
 <html th:fragment="layout (title, content)" xmlns:th="http://www.thymeleaf.org">
 <head>
-    <title th:replace="${title}">Layout Title</title>
+    <title th:replace="${title}?:_">Layout Title</title>
 </head>
 <body>
     <h1>Layout H1</h1>
 </head>
 <body>
     <h1>Layout H1</h1>
-    <div th:replace="${content}">
+    <div th:replace="${content}?:_">
         <p>Layout content</p>
     </div>
     <footer>
         <p>Layout content</p>
     </div>
     <footer>