Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
c68ffa5b
Commit
c68ffa5b
authored
Nov 24, 2015
by
Eddú Meléndez
Committed by
Stephane Nicoll
Jan 26, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Thymeleaf's Java8TimeDialect
Closes gh-4576
parent
24b953ed
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
0 deletions
+40
-0
pom.xml
spring-boot-autoconfigure/pom.xml
+5
-0
ThymeleafAutoConfiguration.java
...t/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
+16
-0
ThymeleafAutoConfigurationTests.java
...oconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
+12
-0
java8time-dialect.html
...igure/src/test/resources/templates/java8time-dialect.html
+1
-0
pom.xml
spring-boot-dependencies/pom.xml
+6
-0
No files found.
spring-boot-autoconfigure/pom.xml
View file @
c68ffa5b
...
...
@@ -505,6 +505,11 @@
<artifactId>
thymeleaf-extras-conditionalcomments
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.thymeleaf.extras
</groupId>
<artifactId>
thymeleaf-extras-java8time
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.thymeleaf.extras
</groupId>
<artifactId>
thymeleaf-extras-springsecurity4
</artifactId>
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
View file @
c68ffa5b
...
...
@@ -29,6 +29,7 @@ import org.apache.commons.logging.Log;
import
org.apache.commons.logging.LogFactory
;
import
org.thymeleaf.dialect.IDialect
;
import
org.thymeleaf.extras.conditionalcomments.dialect.ConditionalCommentsDialect
;
import
org.thymeleaf.extras.java8time.dialect.Java8TimeDialect
;
import
org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect
;
import
org.thymeleaf.spring4.SpringTemplateEngine
;
import
org.thymeleaf.spring4.resourceresolver.SpringResourceResourceResolver
;
...
...
@@ -40,6 +41,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.autoconfigure.AutoConfigureAfter
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnJava
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication
;
...
...
@@ -61,6 +63,7 @@ import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
* @author Andy Wilkinson
* @author Stephane Nicoll
* @author Brian Clozel
* @author Eddú Meléndez
*/
@Configuration
@EnableConfigurationProperties
(
ThymeleafProperties
.
class
)
...
...
@@ -190,6 +193,19 @@ public class ThymeleafAutoConfiguration {
}
@Configuration
@ConditionalOnJava
(
ConditionalOnJava
.
JavaVersion
.
EIGHT
)
@ConditionalOnClass
({
Java8TimeDialect
.
class
})
protected
static
class
ThymeleafJava8TimeDialect
{
@Bean
@ConditionalOnMissingBean
public
Java8TimeDialect
java8TimeDialect
()
{
return
new
Java8TimeDialect
();
}
}
@Configuration
@ConditionalOnClass
({
Servlet
.
class
})
@ConditionalOnWebApplication
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
View file @
c68ffa5b
...
...
@@ -54,6 +54,7 @@ import static org.junit.Assert.assertTrue;
*
* @author Dave Syer
* @author Stephane Nicoll
* @author Eddú Meléndez
*/
public
class
ThymeleafAutoConfigurationTests
{
...
...
@@ -172,6 +173,17 @@ public class ThymeleafAutoConfigurationTests {
assertEquals
(
"<html><body data-foo=\"bar\"></body></html>"
,
result
);
}
@Test
public
void
useJava8TimeDialect
()
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
);
String
result
=
engine
.
process
(
"java8time-dialect"
,
attrs
);
assertEquals
(
"<html><body>2015-11-24</body></html>"
,
result
);
}
@Test
public
void
renderTemplate
()
throws
Exception
{
this
.
context
.
register
(
ThymeleafAutoConfiguration
.
class
,
...
...
spring-boot-autoconfigure/src/test/resources/templates/java8time-dialect.html
0 → 100644
View file @
c68ffa5b
<html><body
th:text=
"${#temporals.create('2015','11','24')}"
></body></html>
\ No newline at end of file
spring-boot-dependencies/pom.xml
View file @
c68ffa5b
...
...
@@ -153,6 +153,7 @@
<thymeleaf-extras-conditionalcomments.version>
2.1.1.RELEASE
</thymeleaf-extras-conditionalcomments.version>
<thymeleaf-layout-dialect.version>
1.3.1
</thymeleaf-layout-dialect.version>
<thymeleaf-extras-data-attribute.version>
1.3
</thymeleaf-extras-data-attribute.version>
<thymeleaf-extras-java8time.version>
2.1.0.RELEASE
</thymeleaf-extras-java8time.version>
<tomcat.version>
8.0.30
</tomcat.version>
<undertow.version>
1.3.14.Final
</undertow.version>
<velocity.version>
1.7
</velocity.version>
...
...
@@ -1963,6 +1964,11 @@
<artifactId>
thymeleaf-extras-conditionalcomments
</artifactId>
<version>
${thymeleaf-extras-conditionalcomments.version}
</version>
</dependency>
<dependency>
<groupId>
org.thymeleaf.extras
</groupId>
<artifactId>
thymeleaf-extras-java8time
</artifactId>
<version>
${thymeleaf-extras-java8time.version}
</version>
</dependency>
<dependency>
<groupId>
org.thymeleaf.extras
</groupId>
<artifactId>
thymeleaf-extras-springsecurity4
</artifactId>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment