Created
August 19, 2016 14:45
-
-
Save nickbabcock/286da838b5f305721b05340acfaa768e to your computer and use it in GitHub Desktop.
dropwizard-partial-mustache
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
diff --git a/dropwizard-views-mustache/src/test/java/io/dropwizard/views/mustache/MustacheViewRendererTest.java b/dropwizard-views-mustache/src/test/java/io/dropwizard/views/mustache/MustacheViewRendererTest.java | |
index 9e08168..0de4fbf 100644 | |
--- a/dropwizard-views-mustache/src/test/java/io/dropwizard/views/mustache/MustacheViewRendererTest.java | |
+++ b/dropwizard-views-mustache/src/test/java/io/dropwizard/views/mustache/MustacheViewRendererTest.java | |
@@ -41,6 +41,18 @@ public class MustacheViewRendererTest extends JerseyTest { | |
} | |
@GET | |
+ @Path("/sub") | |
+ public SubDirectoryView showSub() { | |
+ return new SubDirectoryView(); | |
+ } | |
+ | |
+ @GET | |
+ @Path("/sub-relative") | |
+ public RelativeSubDirectoryView showRelativeSub() { | |
+ return new RelativeSubDirectoryView(); | |
+ } | |
+ | |
+ @GET | |
@Path("/bad") | |
public BadView showBad() { | |
return new BadView(); | |
@@ -76,6 +88,18 @@ public class MustacheViewRendererTest extends JerseyTest { | |
} | |
@Test | |
+ public void rendersViewsWithSubDirectoryTemplatePaths() throws Exception { | |
+ final String response = target("/test/sub").request().get(String.class); | |
+ assertThat(response).isEqualTo("hello\nIt's me!\n\n"); | |
+ } | |
+ | |
+ @Test | |
+ public void rendersViewsWithRelativeSubDirectoryTemplatePaths() throws Exception { | |
+ final String response = target("/test/sub-relative").request().get(String.class); | |
+ assertThat(response).isEqualTo("hello\nIt's me!\n\n"); | |
+ } | |
+ | |
+ @Test | |
public void returnsA500ForViewsWithBadTemplatePaths() throws Exception { | |
try { | |
target("/test/bad").request().get(String.class); | |
diff --git a/dropwizard-views-mustache/src/test/java/io/dropwizard/views/mustache/RelativeSubDirectoryView.java b/dropwizard-views-mustache/src/test/java/io/dropwizard/views/mustache/RelativeSubDirectoryView.java | |
index 71c8102..6bf30e9 100644 | |
--- a/dropwizard-views-mustache/src/test/java/io/dropwizard/views/mustache/RelativeSubDirectoryView.java | |
+++ b/dropwizard-views-mustache/src/test/java/io/dropwizard/views/mustache/RelativeSubDirectoryView.java | |
@@ -1,4 +1,10 @@ | |
package io.dropwizard.views.mustache; | |
-public class AbsoluteSubDirectoryView { | |
+import io.dropwizard.views.View; | |
+ | |
+public class RelativeSubDirectoryView extends View { | |
+ public RelativeSubDirectoryView() { | |
+ super("sub/body.mustache"); | |
+ } | |
+ | |
} | |
diff --git a/dropwizard-views-mustache/src/test/java/io/dropwizard/views/mustache/SubDirectoryView.java b/dropwizard-views-mustache/src/test/java/io/dropwizard/views/mustache/SubDirectoryView.java | |
index a354e1c..bdf4826 100644 | |
--- a/dropwizard-views-mustache/src/test/java/io/dropwizard/views/mustache/SubDirectoryView.java | |
+++ b/dropwizard-views-mustache/src/test/java/io/dropwizard/views/mustache/SubDirectoryView.java | |
@@ -1,4 +1,9 @@ | |
package io.dropwizard.views.mustache; | |
-public class SubDirectoryView { | |
+import io.dropwizard.views.View; | |
+ | |
+public class SubDirectoryView extends View { | |
+ public SubDirectoryView() { | |
+ super("/sub/body.mustache"); | |
+ } | |
} | |
diff --git a/dropwizard-views-mustache/src/test/resources/layout.mustache b/dropwizard-views-mustache/src/test/resources/layout.mustache | |
index e69de29..cf82157 100644 | |
--- a/dropwizard-views-mustache/src/test/resources/layout.mustache | |
+++ b/dropwizard-views-mustache/src/test/resources/layout.mustache | |
@@ -0,0 +1,2 @@ | |
+hello | |
+{{$body}}{{/body}} | |
diff --git a/dropwizard-views-mustache/src/test/resources/sub/body.mustache b/dropwizard-views-mustache/src/test/resources/sub/body.mustache | |
index e69de29..fc5dfa8 100644 | |
--- a/dropwizard-views-mustache/src/test/resources/sub/body.mustache | |
+++ b/dropwizard-views-mustache/src/test/resources/sub/body.mustache | |
@@ -0,0 +1,5 @@ | |
+{{<../layout}} | |
+{{$body}} | |
+It's me! | |
+{{/body}} | |
+{{/../layout}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment