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
ee40fb8c
Commit
ee40fb8c
authored
Jun 17, 2014
by
Max Bruchmann
Committed by
Andy Wilkinson
Jul 29, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add auto-configuration for Thymeleaf data dialect
Closes #1120
parent
53d24301
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
24 deletions
+59
-24
pom.xml
spring-boot-autoconfigure/pom.xml
+5
-0
ThymeleafAutoConfiguration.java
...t/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
+36
-24
ThymeleafAutoConfigurationTests.java
...oconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
+11
-0
data-dialect.html
...oconfigure/src/test/resources/templates/data-dialect.html
+1
-0
pom.xml
spring-boot-dependencies/pom.xml
+6
-0
No files found.
spring-boot-autoconfigure/pom.xml
View file @
ee40fb8c
...
...
@@ -290,6 +290,11 @@
<artifactId>
thymeleaf-layout-dialect
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
com.github.mxab.thymeleaf.extras
</groupId>
<artifactId>
thymeleaf-extras-data-attribute
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.thymeleaf.extras
</groupId>
<artifactId>
thymeleaf-extras-springsecurity3
</artifactId>
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
View file @
ee40fb8c
...
...
@@ -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
();
}
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
View file @
ee40fb8c
...
...
@@ -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
(
"<html><body data-foo=\"bar\"></body></html>"
,
result
);
}
}
spring-boot-autoconfigure/src/test/resources/templates/data-dialect.html
0 → 100644
View file @
ee40fb8c
<html><body
data:foo=
"${foo}"
></body></html>
\ No newline at end of file
spring-boot-dependencies/pom.xml
View file @
ee40fb8c
...
...
@@ -115,6 +115,7 @@
<thymeleaf.version>
2.1.3.RELEASE
</thymeleaf.version>
<thymeleaf-extras-springsecurity3.version>
2.1.1.RELEASE
</thymeleaf-extras-springsecurity3.version>
<thymeleaf-layout-dialect.version>
1.2.5
</thymeleaf-layout-dialect.version>
<thymeleaf-extras-data-attribute.version>
1.3
</thymeleaf-extras-data-attribute.version>
<tomcat.version>
7.0.54
</tomcat.version>
<velocity.version>
1.7
</velocity.version>
<velocity-tools.version>
2.0
</velocity-tools.version>
...
...
@@ -401,6 +402,11 @@
<artifactId>
gemfire
</artifactId>
<version>
${gemfire.version}
</version>
</dependency>
<dependency>
<groupId>
com.github.mxab.thymeleaf.extras
</groupId>
<artifactId>
thymeleaf-extras-data-attribute
</artifactId>
<version>
${thymeleaf-extras-data-attribute.version}
</version>
</dependency>
<dependency>
<groupId>
com.h2database
</groupId>
<artifactId>
h2
</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