From 3b858edfa9edb2a439aeeebbcf8f460c31d3f888 Mon Sep 17 00:00:00 2001 From: Michael Cramer Date: Thu, 11 Dec 2014 10:24:24 +0100 Subject: [PATCH] Auto-configure for Thymeleaf conditionalcomments Add auto-configuration for thymeleaf-extras-conditionalcomments which allows parsing of conditional comments for IE. Example: Without this dialect all Thymeleaf attributes are ignored inside the comment. Fixes gh-2113 --- spring-boot-autoconfigure/pom.xml | 5 +++++ .../thymeleaf/ThymeleafAutoConfiguration.java | 13 +++++++++++++ spring-boot-dependencies/pom.xml | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/spring-boot-autoconfigure/pom.xml b/spring-boot-autoconfigure/pom.xml index 038d7dd2c5..887a37bdee 100644 --- a/spring-boot-autoconfigure/pom.xml +++ b/spring-boot-autoconfigure/pom.xml @@ -375,6 +375,11 @@ thymeleaf-extras-data-attribute true + + org.thymeleaf.extras + thymeleaf-extras-conditionalcomments + 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 87e445a1ef..f0cc34e146 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 @@ -41,6 +41,7 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; import org.springframework.util.Assert; import org.thymeleaf.dialect.IDialect; +import org.thymeleaf.extras.conditionalcomments.dialect.ConditionalCommentsDialect; import org.thymeleaf.extras.springsecurity3.dialect.SpringSecurityDialect; import org.thymeleaf.spring4.SpringTemplateEngine; import org.thymeleaf.spring4.resourceresolver.SpringResourceResourceResolver; @@ -163,6 +164,18 @@ public class ThymeleafAutoConfiguration { } + @Configuration + @ConditionalOnClass(ConditionalCommentsDialect.class) + protected static class ThymeleafConditionalCommentsDialectConfiguration { + + @Bean + @ConditionalOnMissingBean + public ConditionalCommentsDialect conditionalCommentsDialect() { + return new ConditionalCommentsDialect(); + } + + } + @Configuration @ConditionalOnClass({ Servlet.class }) @ConditionalOnWebApplication diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index 59fee6eb9e..2abbfd7c1f 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -127,6 +127,7 @@ ${javax-mail.version} 2.1.3.RELEASE 2.1.1.RELEASE + 2.1.1.RELEASE 1.2.7 1.3 8.0.15 @@ -1404,6 +1405,11 @@ thymeleaf-spring4 ${thymeleaf.version} + + org.thymeleaf.extras + thymeleaf-extras-conditionalcomments + ${thymeleaf-extras-conditionalcomments.version} + org.thymeleaf.extras thymeleaf-extras-springsecurity3