-
Notifications
You must be signed in to change notification settings - Fork 40.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove Thymeleaf's layout dialect from its starter and update samples
Closes gh-7557
- Loading branch information
1 parent
9a7e5ca
commit c00638f
Showing
8 changed files
with
138 additions
and
162 deletions.
There are no files selected for viewing
43 changes: 21 additions & 22 deletions
43
spring-boot-samples/spring-boot-sample-devtools/src/main/resources/templates/hello.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html xmlns:th="http://www.thymeleaf.org" | ||
xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" | ||
layout:decorator="layout"> | ||
<head> | ||
<title>Hello</title> | ||
</head> | ||
<body> | ||
<h1 layout:fragment="header" th:text="${message}">Header</h1> | ||
<div layout:fragment="content"> | ||
<h2 th:text="${sessionVar}">Session Var</h2> | ||
Lorem ipsum dolor sit amet, | ||
consectetur adipiscing elit. Cras ut fringilla augue, quis dictum | ||
turpis. Sed tincidunt mi vel euismod viverra. Nulla facilisi. | ||
Suspendisse mauris dolor, egestas ac leo at, porttitor ullamcorper | ||
leo. Suspendisse consequat, justo ut rutrum interdum, nibh massa | ||
semper dui, id sagittis tellus lectus at nibh. Etiam at scelerisque | ||
nisi. Quisque vel eros tempor, fermentum sapien sed, gravida neque. | ||
Fusce interdum sed dolor a semper. Morbi porta mauris a velit laoreet | ||
viverra. Praesent et tellus vehicula, sagittis mi quis, faucibus urna. | ||
Ut diam tortor, vehicula eget aliquam eget, elementum a odio. Fusce at | ||
nisl sapien. Suspendisse potenti.</div> | ||
</body> | ||
<html xmlns:th="http://www.thymeleaf.org"> | ||
<head> | ||
<title>Hello</title> | ||
</head> | ||
<body> | ||
<h1 th:text="${message}">Header</h1> | ||
<div class="content"> | ||
<h2 th:text="${sessionVar}">Session Var</h2> | ||
Lorem ipsum dolor sit amet, | ||
consectetur adipiscing elit. Cras ut fringilla augue, quis dictum | ||
turpis. Sed tincidunt mi vel euismod viverra. Nulla facilisi. | ||
Suspendisse mauris dolor, egestas ac leo at, porttitor ullamcorper | ||
leo. Suspendisse consequat, justo ut rutrum interdum, nibh massa | ||
semper dui, id sagittis tellus lectus at nibh. Etiam at scelerisque | ||
nisi. Quisque vel eros tempor, fermentum sapien sed, gravida neque. | ||
Fusce interdum sed dolor a semper. Morbi porta mauris a velit laoreet | ||
viverra. Praesent et tellus vehicula, sagittis mi quis, faucibus urna. | ||
Ut diam tortor, vehicula eget aliquam eget, elementum a odio. Fusce at | ||
nisl sapien. Suspendisse potenti. | ||
</div> | ||
</body> | ||
</html> |
12 changes: 0 additions & 12 deletions
12
spring-boot-samples/spring-boot-sample-devtools/src/main/resources/templates/layout.html
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
spring-boot-samples/spring-boot-sample-web-ui/src/main/resources/templates/fragments.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html xmlns:th="http://www.thymeleaf.org"> | ||
<head th:fragment="head (title)"> | ||
<title th:text="${title}">Fragments</title> | ||
<link rel="stylesheet" th:href="@{/css/bootstrap.min.css}" | ||
href="../../css/bootstrap.min.css" /> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div th:fragment="navbar" class="navbar"> | ||
<div class="navbar-inner"> | ||
<a class="brand" href="http://thymeleaf.org">Thymeleaf</a> | ||
<ul class="nav"> | ||
<li><a th:href="@{/}" href="messages.html"> Messages </a></li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
25 changes: 0 additions & 25 deletions
25
spring-boot-samples/spring-boot-sample-web-ui/src/main/resources/templates/layout.html
This file was deleted.
Oops, something went wrong.
63 changes: 31 additions & 32 deletions
63
...ng-boot-samples/spring-boot-sample-web-ui/src/main/resources/templates/messages/form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html xmlns:th="http://www.thymeleaf.org" | ||
xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" | ||
layout:decorator="layout"> | ||
<head> | ||
<title>Messages : Create</title> | ||
</head> | ||
<body> | ||
<h1 layout:fragment="header">Messages : Create</h1> | ||
<div layout:fragment="content" class="container"> | ||
<form id="messageForm" th:action="@{/(form)}" th:object="${message}" | ||
action="#" method="post"> | ||
<div th:if="${#fields.hasErrors('*')}" class="alert alert-error"> | ||
<p th:each="error : ${#fields.errors('*')}" th:text="${error}"> | ||
Validation error</p> | ||
</div> | ||
<div class="pull-right"> | ||
<a th:href="@{/}" href="messages.html"> Messages </a> | ||
</div> | ||
<input type="hidden" th:field="*{id}" | ||
th:class="${#fields.hasErrors('id')} ? 'field-error'" /> <label | ||
for="summary">Summary</label> <input type="text" | ||
th:field="*{summary}" | ||
th:class="${#fields.hasErrors('summary')} ? 'field-error'" /> <label | ||
for="text">Message</label> | ||
<textarea th:field="*{text}" | ||
th:class="${#fields.hasErrors('text')} ? 'field-error'"></textarea> | ||
<div class="form-actions"> | ||
<input type="submit" value="Save" /> | ||
</div> | ||
</form> | ||
</div> | ||
</body> | ||
<html xmlns:th="http://www.thymeleaf.org"> | ||
<head th:replace="fragments :: head(title='Messages : Create')"> | ||
<title>Messages : Create</title> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div th:replace="fragments :: navbar"></div> | ||
<h1>Messages : Create</h1> | ||
<form id="messageForm" th:action="@{/(form)}" th:object="${message}" | ||
action="#" method="post"> | ||
<div th:if="${#fields.hasErrors('*')}" class="alert alert-error"> | ||
<p th:each="error : ${#fields.errors('*')}" th:text="${error}"> | ||
Validation error</p> | ||
</div> | ||
<div class="pull-right"> | ||
<a th:href="@{/}" href="messages.html"> Messages </a> | ||
</div> | ||
<input type="hidden" th:field="*{id}" | ||
th:class="${#fields.hasErrors('id')} ? 'field-error'" /> <label | ||
for="summary">Summary</label> <input type="text" | ||
th:field="*{summary}" | ||
th:class="${#fields.hasErrors('summary')} ? 'field-error'" /> <label | ||
for="text">Message</label> | ||
<textarea th:field="*{text}" | ||
th:class="${#fields.hasErrors('text')} ? 'field-error'"></textarea> | ||
<div class="form-actions"> | ||
<input type="submit" value="Save" /> | ||
</div> | ||
</form> | ||
</div> | ||
</body> | ||
</html> |
69 changes: 35 additions & 34 deletions
69
...ng-boot-samples/spring-boot-sample-web-ui/src/main/resources/templates/messages/list.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
<!DOCTYPE html> | ||
<html xmlns:th="http://www.thymeleaf.org" | ||
xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" | ||
layout:decorator="layout"> | ||
<head> | ||
<title>Messages : View all</title> | ||
</head> | ||
<body> | ||
<h1 layout:fragment="header">Messages : View all</h1> | ||
<div layout:fragment="content" class="container"> | ||
<div class="pull-right"> | ||
<a href="form.html" th:href="@{/(form)}">Create Message</a> | ||
<html xmlns:th="http://www.thymeleaf.org"> | ||
<head th:replace="fragments :: head(title='Messages : View all')"> | ||
<title>Messages : View all</title> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div th:replace="fragments :: navbar"></div> | ||
<h1>Messages : View all</h1> | ||
<div class="container"> | ||
<div class="pull-right"> | ||
<a href="form.html" th:href="@{/(form)}">Create Message</a> | ||
</div> | ||
<table class="table table-bordered table-striped"> | ||
<thead> | ||
<tr> | ||
<td>ID</td> | ||
<td>Created</td> | ||
<td>Summary</td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr th:if="${messages.empty}"> | ||
<td colspan="3">No messages</td> | ||
</tr> | ||
<tr th:each="message : ${messages}"> | ||
<td th:text="${message.id}">1</td> | ||
<td th:text="${#calendars.format(message.created)}">July 11, | ||
2012 2:17:16 PM CDT</td> | ||
<td><a href="view.html" th:href="@{'/' + ${message.id}}" | ||
th:text="${message.summary}"> The summary </a></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
<table class="table table-bordered table-striped"> | ||
<thead> | ||
<tr> | ||
<td>ID</td> | ||
<td>Created</td> | ||
<td>Summary</td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr th:if="${messages.empty}"> | ||
<td colspan="3">No messages</td> | ||
</tr> | ||
<tr th:each="message : ${messages}"> | ||
<td th:text="${message.id}">1</td> | ||
<td th:text="${#calendars.format(message.created)}">July 11, | ||
2012 2:17:16 PM CDT</td> | ||
<td><a href="view.html" th:href="@{'/' + ${message.id}}" | ||
th:text="${message.summary}"> The summary </a></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</body> | ||
</body> | ||
</html> |
64 changes: 31 additions & 33 deletions
64
...ng-boot-samples/spring-boot-sample-web-ui/src/main/resources/templates/messages/view.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,33 @@ | ||
<html xmlns:th="http://www.thymeleaf.org" | ||
xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" | ||
layout:decorator="layout"> | ||
<head> | ||
<title>Messages : View</title> | ||
</head> | ||
<body> | ||
<h1 layout:fragment="header">Messages : Create</h1> | ||
<div layout:fragment="content" class="container"> | ||
<div class="alert alert-success" th:if="${globalMessage}" | ||
th:text="${globalMessage}">Some Success message</div> | ||
<div class="pull-right"> | ||
<a th:href="@{/}" href="list.html"> Messages </a> | ||
<!DOCTYPE html> | ||
<html xmlns:th="http://www.thymeleaf.org"> | ||
<head th:replace="fragments :: head(title='Messages : View')"> | ||
<title>Messages : View</title> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div th:replace="fragments :: navbar"></div> | ||
<h1>Messages : View</h1> | ||
<div class="alert alert-success" th:if="${globalMessage}" | ||
th:text="${globalMessage}">Some Success message</div> | ||
<div class="pull-right"> | ||
<a th:href="@{/}" href="list.html"> Messages </a> | ||
</div> | ||
<dl> | ||
<dt>ID</dt> | ||
<dd id="id" th:text="${message.id}">123</dd> | ||
<dt>Date</dt> | ||
<dd id="created" th:text="${#calendars.format(message.created)}"> | ||
July 11, 2012 2:17:16 PM CDT</dd> | ||
<dt>Summary</dt> | ||
<dd id="summary" th:text="${message.summary}">A short summary...</dd> | ||
<dt>Message</dt> | ||
<dd id="text" th:text="${message.text}">A detailed message that | ||
is longer than the summary.</dd> | ||
</dl> | ||
<div class="pull-left"> | ||
<a href="messages" th:href="@{'/delete/' + ${message.id}}">delete </a> | | ||
<a href="form.html" th:href="@{'/modify/' + ${message.id}}"> modify </a> | ||
</div> | ||
</div> | ||
<dl> | ||
<dt>ID</dt> | ||
<dd id="id" th:text="${message.id}">123</dd> | ||
<dt>Date</dt> | ||
<dd id="created" th:text="${#calendars.format(message.created)}"> | ||
July 11, 2012 2:17:16 PM CDT</dd> | ||
<dt>Summary</dt> | ||
<dd id="summary" th:text="${message.summary}">A short summary... | ||
</dd> | ||
<dt>Message</dt> | ||
<dd id="text" th:text="${message.text}">A detailed message that | ||
is longer than the summary.</dd> | ||
</dl> | ||
<div class="pull-left"> | ||
<a href="messages" th:href="@{'/delete/' + ${message.id}}"> | ||
delete </a> | <a href="form.html" | ||
th:href="@{'/modify/' + ${message.id}}"> modify </a> | ||
</div> | ||
</div> | ||
</body> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c00638f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small comment about this (and equivalent calls):
Since Thymeleaf 3.0, this could also be done without repeating the title text using a fragment expression as an argument, like:
And then at
fragments.html
the same you have now:...or alternatively select the whole
<title>
tag in the fragment expression:And then use
th:replace
atfragments.html
:More on this: http://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#flexible-layouts-beyond-mere-fragment-insertion
c00638f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @danielfernandez. I've opened #8137.