I'm using Spring Boot and I want to add the IE conditional comments Thymeleaf dialect.
I've included it in my maven pom.xml, but it's not working. How do I tell Thymeleaf to use it?
Dialects. Thymeleaf Dialects are sets of features we can use in your templates. These features include: Processing logic specified via processors that apply to attributes in our tags (or tags themselves).
We can implement Thymeleaf template engine by adding spring-boot-starter-thymeleaf dependency in our application's pom. xml file. Spring Boot configures template engine to read template file from /resource/templates.
NOTE: Before trying this, note that later versions of Spring Boot include some of the common dialects out of the box. See @Robert Hunt's answer. Otherwise:
There is an example here of adding Dialect beans, which Spring Boot will automagically detect and use (see the LayoutDialect code and the dialects member of the ThymeleafDefaultConfiguration class). In your case, add the following in of one of your @Configuration
classes:
@Bean public ConditionalCommentsDialect conditionalCommentDialect() { return new ConditionalCommentsDialect(); }
Spring Boot, in the ThymeleafAutoConfiguration class, will automatically add any Beans that implement the IDialect interface.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With