model) {
+ model.put("time", new Date());
+ model.put("message", "Hello World");
+ model.put("title", "Hello App");
+ return "partial";
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+
+ }
+
+}
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheTemplateStandaloneTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheTemplateStandaloneTests.java
new file mode 100644
index 0000000000..5036c38956
--- /dev/null
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheTemplateStandaloneTests.java
@@ -0,0 +1,62 @@
+package org.springframework.boot.autoconfigure.mustache;
+
+import java.util.Collections;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
+import org.springframework.boot.autoconfigure.mustache.MustacheTemplateStandaloneTests.Application;
+import org.springframework.boot.test.IntegrationTest;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.samskivert.mustache.Mustache;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(classes = Application.class)
+@IntegrationTest({ "spring.main.web_environment=false", "env.foo=Heaven", "foo=World" })
+public class MustacheTemplateStandaloneTests {
+
+ @Autowired
+ private Mustache.Compiler compiler;
+
+ @Test
+ public void directCompilation() throws Exception {
+ assertEquals(
+ "Hello: World",
+ this.compiler.compile("Hello: {{world}}").execute(
+ Collections.singletonMap("world", "World")));
+ }
+
+ @Test
+ public void environmentCollectorCompoundKey() throws Exception {
+ assertEquals("Hello: Heaven", this.compiler.compile("Hello: {{env.foo}}")
+ .execute(new Object()));
+ }
+
+ @Test
+ public void environmentCollectorCompoundKeyStandard() throws Exception {
+ assertEquals(
+ "Hello: Heaven",
+ this.compiler.standardsMode(true).compile("Hello: {{env.foo}}")
+ .execute(new Object()));
+ }
+
+ @Test
+ public void environmentCollectorSimpleKey() throws Exception {
+ assertEquals("Hello: World",
+ this.compiler.compile("Hello: {{foo}}").execute(new Object()));
+ }
+
+ @Configuration
+ @Import({ MustacheAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
+ protected static class Application {
+
+ }
+
+}
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheViewResolverTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheViewResolverTests.java
new file mode 100644
index 0000000000..f4167b3a9e
--- /dev/null
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheViewResolverTests.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2012-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.boot.autoconfigure.mustache;
+
+import java.util.Locale;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.boot.autoconfigure.mustache.web.MustacheViewResolver;
+import org.springframework.mock.web.MockServletContext;
+import org.springframework.web.context.support.StaticWebApplicationContext;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+/**
+ * @author Dave Syer
+ *
+ */
+public class MustacheViewResolverTests {
+
+ private MustacheViewResolver resolver = new MustacheViewResolver();
+
+ @Before
+ public void init() {
+ this.resolver.setApplicationContext(new StaticWebApplicationContext());
+ this.resolver.setServletContext(new MockServletContext());
+ this.resolver.setPrefix("classpath:/mustache-templates/");
+ this.resolver.setSuffix(".html");
+ }
+
+ @Test
+ public void resolveNonExistent() throws Exception {
+ assertNull(this.resolver.resolveViewName("bar", null));
+ }
+
+ @Test
+ public void resolveNullLocale() throws Exception {
+ assertNotNull(this.resolver.resolveViewName("foo", null));
+ }
+
+ @Test
+ public void resolveDefaultLocale() throws Exception {
+ assertNotNull(this.resolver.resolveViewName("foo", Locale.US));
+ }
+
+ @Test
+ public void resolveDoubleLocale() throws Exception {
+ assertNotNull(this.resolver.resolveViewName("foo", Locale.CANADA_FRENCH));
+ }
+
+ @Test
+ public void resolveTripleLocale() throws Exception {
+ assertNotNull(this.resolver.resolveViewName("foo", new Locale("en", "GB", "cy")));
+ }
+
+ @Test
+ public void resolveSpecificLocale() throws Exception {
+ assertNotNull(this.resolver.resolveViewName("foo", new Locale("de")));
+ }
+
+}
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheViewTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheViewTests.java
new file mode 100644
index 0000000000..5675683e05
--- /dev/null
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mustache/MustacheViewTests.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2012-2013 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.boot.autoconfigure.mustache;
+
+import java.util.Collections;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.boot.autoconfigure.mustache.web.MustacheView;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.mock.web.MockServletContext;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
+
+import com.samskivert.mustache.Mustache;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Dave Syer
+ *
+ */
+public class MustacheViewTests {
+
+ private MockHttpServletRequest request = new MockHttpServletRequest();
+
+ private MockHttpServletResponse response = new MockHttpServletResponse();
+
+ private AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
+
+ @Before
+ public void init() {
+ this.context.refresh();
+ MockServletContext servletContext = new MockServletContext();
+ this.context.setServletContext(servletContext);
+ servletContext.setAttribute(
+ WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
+ this.context);
+ }
+
+ @Test
+ public void viewResolvesHandlebars() throws Exception {
+ MustacheView view = new MustacheView(Mustache.compiler().compile("Hello {{msg}}"));
+ view.setApplicationContext(this.context);
+ view.render(Collections.singletonMap("msg", "World"), this.request, this.response);
+ assertEquals("Hello World", this.response.getContentAsString());
+ }
+
+}
diff --git a/spring-boot-autoconfigure/src/test/resources/mustache-templates/content.html b/spring-boot-autoconfigure/src/test/resources/mustache-templates/content.html
new file mode 100644
index 0000000000..3addef973e
--- /dev/null
+++ b/spring-boot-autoconfigure/src/test/resources/mustache-templates/content.html
@@ -0,0 +1,2 @@
+A Message
+{{message}} at {{time}}
diff --git a/spring-boot-autoconfigure/src/test/resources/mustache-templates/foo.html b/spring-boot-autoconfigure/src/test/resources/mustache-templates/foo.html
new file mode 100644
index 0000000000..18624afa99
--- /dev/null
+++ b/spring-boot-autoconfigure/src/test/resources/mustache-templates/foo.html
@@ -0,0 +1 @@
+Hello {{World}}
\ No newline at end of file
diff --git a/spring-boot-autoconfigure/src/test/resources/mustache-templates/foo_de.html b/spring-boot-autoconfigure/src/test/resources/mustache-templates/foo_de.html
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/spring-boot-autoconfigure/src/test/resources/mustache-templates/home.html b/spring-boot-autoconfigure/src/test/resources/mustache-templates/home.html
new file mode 100644
index 0000000000..0e134df2ec
--- /dev/null
+++ b/spring-boot-autoconfigure/src/test/resources/mustache-templates/home.html
@@ -0,0 +1,9 @@
+
+
+{{title}}
+
+
+ A Message
+ {{message}} at {{time}}
+
+
\ No newline at end of file
diff --git a/spring-boot-autoconfigure/src/test/resources/mustache-templates/layout.html b/spring-boot-autoconfigure/src/test/resources/mustache-templates/layout.html
new file mode 100644
index 0000000000..762ded630f
--- /dev/null
+++ b/spring-boot-autoconfigure/src/test/resources/mustache-templates/layout.html
@@ -0,0 +1,15 @@
+
+
+{{title}}
+
+
+
+ {{#include}}{{body}}{{/include}}
+
+
\ No newline at end of file
diff --git a/spring-boot-autoconfigure/src/test/resources/mustache-templates/partial.html b/spring-boot-autoconfigure/src/test/resources/mustache-templates/partial.html
new file mode 100644
index 0000000000..6bea208a58
--- /dev/null
+++ b/spring-boot-autoconfigure/src/test/resources/mustache-templates/partial.html
@@ -0,0 +1,15 @@
+
+
+{{title}}
+
+
+
+ {{>content}}
+
+
\ No newline at end of file
diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml
index 614faac264..479a15f289 100644
--- a/spring-boot-dependencies/pom.xml
+++ b/spring-boot-dependencies/pom.xml
@@ -1,4 +1,6 @@
-
+
+
4.0.0
org.springframework.boot
spring-boot-dependencies
@@ -88,6 +90,7 @@
2.14
9.2.4.v20141103
2.2.0.v201112011158
+ 1.9
2.5
1.2.3
0.9.1
@@ -324,6 +327,11 @@
spring-boot-starter-mobile
1.2.2.BUILD-SNAPSHOT