From: Kai Moritz Date: Thu, 16 Jan 2020 09:16:23 +0000 (+0100) Subject: Separated layout from content with Thymeleaf X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=8fda1e5a750a098fd9b03b10e78d9377aa96633d;p=demos%2Ftesting Separated layout from content with Thymeleaf --- diff --git a/src/main/java/de/juplo/demo/HtmlController.java b/src/main/java/de/juplo/demo/HtmlController.java index eaa2fcc..5696718 100644 --- a/src/main/java/de/juplo/demo/HtmlController.java +++ b/src/main/java/de/juplo/demo/HtmlController.java @@ -27,6 +27,6 @@ public class HtmlController public String fetch(Model model, @RequestParam String path) { model.addAttribute("text", service.getRemoteText(path)); - return "layout"; + return "home"; } } diff --git a/src/main/resources/templates/home.html b/src/main/resources/templates/home.html new file mode 100644 index 0000000..6076f98 --- /dev/null +++ b/src/main/resources/templates/home.html @@ -0,0 +1,13 @@ + + + + + Shows Remote-Content + + +

Fetched Data

+
+
TEXT
+
+ + diff --git a/src/main/resources/templates/layout.html b/src/main/resources/templates/layout.html index bc5799a..233b937 100644 --- a/src/main/resources/templates/layout.html +++ b/src/main/resources/templates/layout.html @@ -1,9 +1,9 @@ - + - Shows Remote-Content + TITLE @@ -11,11 +11,9 @@
-
-

Information About Fetched Data

-
-

TEXT

-
+
+

HEADER

+
BODY
diff --git a/src/test/java/de/juplo/demo/HtmlControllerTest.java b/src/test/java/de/juplo/demo/HtmlControllerTest.java index ceb14e4..1cf7274 100644 --- a/src/test/java/de/juplo/demo/HtmlControllerTest.java +++ b/src/test/java/de/juplo/demo/HtmlControllerTest.java @@ -47,7 +47,7 @@ public class HtmlControllerTest String result = controller.fetch(model, "foo"); - assertThat(result).isEqualTo("layout"); + assertThat(result).isEqualTo("home"); ArgumentCaptor> captor = ArgumentCaptor.forClass(Mono.class); verify(model).addAttribute(eq("text"), captor.capture()); StepVerifier