forked from PebbleTemplates/pebble
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set proxyBeanMethods to false (PebbleTemplates#507)
- Loading branch information
1 parent
3756cf2
commit 80d5896
Showing
11 changed files
with
143 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
.../main/java/com/mitchellbosecke/pebble/boot/autoconfigure/AbstractPebbleConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.mitchellbosecke.pebble.boot.autoconfigure; | ||
|
||
abstract class AbstractPebbleConfiguration { | ||
|
||
protected String stripLeadingSlash(String value) { | ||
if (value == null) { | ||
return null; | ||
} | ||
if (value.startsWith("/")) { | ||
return value.substring(1); | ||
} | ||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...in/java/com/mitchellbosecke/pebble/boot/autoconfigure/PebbleReactiveWebConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.mitchellbosecke.pebble.boot.autoconfigure; | ||
|
||
import com.mitchellbosecke.pebble.PebbleEngine; | ||
import com.mitchellbosecke.pebble.loader.ClasspathLoader; | ||
import com.mitchellbosecke.pebble.spring.reactive.PebbleReactiveViewResolver; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
@ConditionalOnWebApplication(type = Type.REACTIVE) | ||
class PebbleReactiveWebConfiguration extends AbstractPebbleConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(name = "pebbleReactiveViewResolver") | ||
PebbleReactiveViewResolver pebbleReactiveViewResolver(PebbleProperties properties, | ||
PebbleEngine pebbleEngine) { | ||
String prefix = properties.getPrefix(); | ||
if (pebbleEngine.getLoader() instanceof ClasspathLoader) { | ||
// classpathloader doesn't like leading slashes in paths | ||
prefix = this.stripLeadingSlash(properties.getPrefix()); | ||
} | ||
PebbleReactiveViewResolver resolver = new PebbleReactiveViewResolver(pebbleEngine); | ||
resolver.setPrefix(prefix); | ||
resolver.setSuffix(properties.getSuffix()); | ||
resolver.setViewNames(properties.getViewNames()); | ||
resolver.setRequestContextAttribute(properties.getRequestContextAttribute()); | ||
return resolver; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...ain/java/com/mitchellbosecke/pebble/boot/autoconfigure/PebbleServletWebConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.mitchellbosecke.pebble.boot.autoconfigure; | ||
|
||
import com.mitchellbosecke.pebble.PebbleEngine; | ||
import com.mitchellbosecke.pebble.loader.ClasspathLoader; | ||
import com.mitchellbosecke.pebble.spring.servlet.PebbleViewResolver; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
@ConditionalOnWebApplication(type = Type.SERVLET) | ||
class PebbleServletWebConfiguration extends AbstractPebbleConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(name = "pebbleViewResolver") | ||
PebbleViewResolver pebbleViewResolver(PebbleProperties properties, | ||
PebbleEngine pebbleEngine) { | ||
PebbleViewResolver pvr = new PebbleViewResolver(); | ||
properties.applyToMvcViewResolver(pvr); | ||
|
||
pvr.setPebbleEngine(pebbleEngine); | ||
if (pebbleEngine.getLoader() instanceof ClasspathLoader) { | ||
// classpathloader doesn't like leading slashes in paths | ||
pvr.setPrefix(this.stripLeadingSlash(properties.getPrefix())); | ||
} | ||
|
||
return pvr; | ||
} | ||
} |
17 changes: 0 additions & 17 deletions
17
...-spring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/NonWebApplication.java
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
...pring-boot-starter/src/test/java/com/mitchellbosecke/pebble/boot/ReactiveApplication.java
This file was deleted.
Oops, something went wrong.
13 changes: 6 additions & 7 deletions
13
...t-starter/src/test/java/com/mitchellbosecke/pebble/boot/autoconfigure/NonWebAppTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.