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
d69e0486
Commit
d69e0486
authored
Feb 15, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow Thymeleaf's LayoutDialect to be overridden
Closes gh-5151
parent
b726974b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
ThymeleafAutoConfiguration.java
...t/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
+1
-0
ThymeleafAutoConfigurationTests.java
...oconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
+28
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
View file @
d69e0486
...
@@ -148,6 +148,7 @@ public class ThymeleafAutoConfiguration {
...
@@ -148,6 +148,7 @@ public class ThymeleafAutoConfiguration {
protected
static
class
ThymeleafWebLayoutConfiguration
{
protected
static
class
ThymeleafWebLayoutConfiguration
{
@Bean
@Bean
@ConditionalOnMissingBean
public
LayoutDialect
layoutDialect
()
{
public
LayoutDialect
layoutDialect
()
{
return
new
LayoutDialect
();
return
new
LayoutDialect
();
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
View file @
d69e0486
...
@@ -20,6 +20,8 @@ import java.io.File;
...
@@ -20,6 +20,8 @@ import java.io.File;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Locale
;
import
java.util.Locale
;
import
nz.net.ultraq.thymeleaf.LayoutDialect
;
import
nz.net.ultraq.thymeleaf.decorators.strategies.GroupingStrategy
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Rule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -31,18 +33,24 @@ import org.thymeleaf.templateresolver.ITemplateResolver;
...
@@ -31,18 +33,24 @@ import org.thymeleaf.templateresolver.ITemplateResolver;
import
org.thymeleaf.templateresolver.TemplateResolver
;
import
org.thymeleaf.templateresolver.TemplateResolver
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration
;
import
org.springframework.boot.autoconfigure.test.ImportAutoConfiguration
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.boot.test.OutputCapture
;
import
org.springframework.boot.test.OutputCapture
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.mock.web.MockHttpServletResponse
;
import
org.springframework.mock.web.MockHttpServletResponse
;
import
org.springframework.mock.web.MockServletContext
;
import
org.springframework.mock.web.MockServletContext
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
org.springframework.web.servlet.ViewResolver
;
import
org.springframework.web.servlet.ViewResolver
;
import
org.springframework.web.servlet.resource.ResourceUrlEncodingFilter
;
import
org.springframework.web.servlet.resource.ResourceUrlEncodingFilter
;
import
org.springframework.web.servlet.support.RequestContext
;
import
org.springframework.web.servlet.support.RequestContext
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
instanceOf
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertArrayEquals
;
import
static
org
.
junit
.
Assert
.
assertArrayEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
...
@@ -221,4 +229,24 @@ public class ThymeleafAutoConfigurationTests {
...
@@ -221,4 +229,24 @@ public class ThymeleafAutoConfigurationTests {
assertNotNull
(
this
.
context
.
getBean
(
ResourceUrlEncodingFilter
.
class
));
assertNotNull
(
this
.
context
.
getBean
(
ResourceUrlEncodingFilter
.
class
));
}
}
@Test
public
void
layoutDialectCanBeCustomized
()
throws
Exception
{
this
.
context
.
register
(
LayoutDialectConfiguration
.
class
);
this
.
context
.
refresh
();
LayoutDialect
layoutDialect
=
this
.
context
.
getBean
(
LayoutDialect
.
class
);
assertThat
(
ReflectionTestUtils
.
getField
(
layoutDialect
,
"sortingStrategy"
),
is
(
instanceOf
(
GroupingStrategy
.
class
)));
}
@Configuration
@ImportAutoConfiguration
({
ThymeleafAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
})
static
class
LayoutDialectConfiguration
{
@Bean
public
LayoutDialect
layoutDialect
()
{
return
new
LayoutDialect
(
new
GroupingStrategy
());
}
}
}
}
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