diff --git a/spring-boot-autoconfigure/pom.xml b/spring-boot-autoconfigure/pom.xml
index 3a7a816b1bd..89f18db8c55 100644
--- a/spring-boot-autoconfigure/pom.xml
+++ b/spring-boot-autoconfigure/pom.xml
@@ -290,6 +290,11 @@
thymeleaf-layout-dialect
true
+
+ com.github.mxab.thymeleaf.extras
+ thymeleaf-extras-data-attribute
+ true
+
org.thymeleaf.extras
thymeleaf-extras-springsecurity3
diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
index 613399869fd..1783291872c 100644
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
+++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
@@ -47,6 +47,8 @@ import org.thymeleaf.spring4.view.ThymeleafViewResolver;
import org.thymeleaf.templateresolver.ITemplateResolver;
import org.thymeleaf.templateresolver.TemplateResolver;
+import com.github.mxab.thymeleaf.extras.dataattribute.dialect.DataAttributeDialect;
+
/**
* {@link EnableAutoConfiguration Auto-configuration} for Thymeleaf.
*
@@ -66,7 +68,7 @@ public class ThymeleafAutoConfiguration {
@Configuration
@ConditionalOnMissingBean(name = "defaultTemplateResolver")
- public static class DefaultTemplateResolverConfiguration {
+ public static class DefaultTemplateResolverConfiguration {
@Autowired
private ThymeleafProperties properties;
@@ -74,12 +76,12 @@ public class ThymeleafAutoConfiguration {
@Autowired
private final ResourceLoader resourceLoader = new DefaultResourceLoader();
-
@PostConstruct
public void checkTemplateLocationExists() {
Boolean checkTemplateLocation = this.properties.isCheckTemplateLocation();
if (checkTemplateLocation) {
- Resource resource = this.resourceLoader.getResource(this.properties.getPrefix());
+ Resource resource = this.resourceLoader.getResource(this.properties
+ .getPrefix());
Assert.state(resource.exists(), "Cannot find template location: "
+ resource + " (please add some templates "
+ "or check your Thymeleaf configuration)");
@@ -126,7 +128,7 @@ public class ThymeleafAutoConfiguration {
private String[] excludedViewNames;
public boolean isCheckTemplateLocation() {
- return checkTemplateLocation;
+ return this.checkTemplateLocation;
}
public void setCheckTemplateLocation(boolean checkTemplateLocation) {
@@ -134,7 +136,7 @@ public class ThymeleafAutoConfiguration {
}
public String getPrefix() {
- return prefix;
+ return this.prefix;
}
public void setPrefix(String prefix) {
@@ -142,7 +144,7 @@ public class ThymeleafAutoConfiguration {
}
public String getSuffix() {
- return suffix;
+ return this.suffix;
}
public void setSuffix(String suffix) {
@@ -150,7 +152,7 @@ public class ThymeleafAutoConfiguration {
}
public String getMode() {
- return mode;
+ return this.mode;
}
public void setMode(String mode) {
@@ -158,7 +160,7 @@ public class ThymeleafAutoConfiguration {
}
public String getEncoding() {
- return encoding;
+ return this.encoding;
}
public void setEncoding(String encoding) {
@@ -166,7 +168,7 @@ public class ThymeleafAutoConfiguration {
}
public String getContentType() {
- return contentType;
+ return this.contentType;
}
public void setContentType(String contentType) {
@@ -174,7 +176,7 @@ public class ThymeleafAutoConfiguration {
}
public boolean isCache() {
- return cache;
+ return this.cache;
}
public void setCache(boolean cache) {
@@ -182,7 +184,7 @@ public class ThymeleafAutoConfiguration {
}
public String[] getExcludedViewNames() {
- return excludedViewNames;
+ return this.excludedViewNames;
}
public void setExcludedViewNames(String[] excludedViewNames) {
@@ -190,7 +192,7 @@ public class ThymeleafAutoConfiguration {
}
public String[] getViewNames() {
- return viewNames;
+ return this.viewNames;
}
public void setViewNames(String[] viewNames) {
@@ -234,6 +236,28 @@ public class ThymeleafAutoConfiguration {
}
+ @Configuration
+ @ConditionalOnClass(DataAttributeDialect.class)
+ protected static class DataAttributeDialectConfiguration {
+
+ @Bean
+ public DataAttributeDialect dialect() {
+ return new DataAttributeDialect();
+ }
+
+ }
+
+ @Configuration
+ @ConditionalOnClass({ SpringSecurityDialect.class })
+ protected static class ThymeleafSecurityDialectConfiguration {
+
+ @Bean
+ public SpringSecurityDialect securityDialect() {
+ return new SpringSecurityDialect();
+ }
+
+ }
+
@Configuration
@ConditionalOnClass({ Servlet.class })
protected static class ThymeleafViewResolverConfiguration {
@@ -241,7 +265,6 @@ public class ThymeleafAutoConfiguration {
@Autowired
private ThymeleafProperties properties;
-
@Autowired
private SpringTemplateEngine templateEngine;
@@ -270,15 +293,4 @@ public class ThymeleafAutoConfiguration {
}
- @Configuration
- @ConditionalOnClass({ SpringSecurityDialect.class })
- protected static class ThymeleafSecurityDialectConfiguration {
-
- @Bean
- public SpringSecurityDialect securityDialect() {
- return new SpringSecurityDialect();
- }
-
- }
-
}
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
index 89f69be6b2a..629b300771f 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
@@ -137,4 +137,15 @@ public class ThymeleafAutoConfigurationTests {
context.close();
}
+ @Test
+ public void useDataDialect() throws Exception {
+ this.context.register(ThymeleafAutoConfiguration.class,
+ PropertyPlaceholderAutoConfiguration.class);
+ this.context.refresh();
+ TemplateEngine engine = this.context.getBean(TemplateEngine.class);
+ Context attrs = new Context(Locale.UK, Collections.singletonMap("foo", "bar"));
+ String result = engine.process("data-dialect", attrs);
+ assertEquals("", result);
+ }
+
}
diff --git a/spring-boot-autoconfigure/src/test/resources/templates/data-dialect.html b/spring-boot-autoconfigure/src/test/resources/templates/data-dialect.html
new file mode 100644
index 00000000000..8f8a82b4081
--- /dev/null
+++ b/spring-boot-autoconfigure/src/test/resources/templates/data-dialect.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml
index 32b770c9e18..a5127ed5bac 100644
--- a/spring-boot-dependencies/pom.xml
+++ b/spring-boot-dependencies/pom.xml
@@ -115,6 +115,7 @@
2.1.3.RELEASE
2.1.1.RELEASE
1.2.5
+ 1.3
7.0.54
1.7
2.0
@@ -401,6 +402,11 @@
gemfire
${gemfire.version}
+
+ com.github.mxab.thymeleaf.extras
+ thymeleaf-extras-data-attribute
+ ${thymeleaf-extras-data-attribute.version}
+
com.h2database
h2