Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PebbleTemplateAvailabilityProvider doesn't find template files from the classpath #464

Closed
kzmi opened this issue Aug 22, 2019 · 4 comments
Closed
Milestone

Comments

@kzmi
Copy link

kzmi commented Aug 22, 2019

Spring Boot : 2.1.7
pebble-spring-boot-starter : 3.1.0

PebbleTemplateAvailabilityProvider always fails to find the template files like:

  • {classpath}/templates/index.pebble
  • {classpath}/templates/error/404.pebble

In PebbleTemplateAvailabilityProvider.java, this code returns always false.

return resourceLoader.getResource(prefix + view + suffix).exists();

resourceLoader was AnnotationConfigServletWebServerApplicationContext in my app, and the getResource() needs "classpath:" prefix to find a template file.

Before commit 0229ac7, PebbleTemplateAvailabilityProvider does so.

return resourceLoader
          .getResource(ResourceLoader.CLASSPATH_URL_PREFIX + prefix + view + suffix).exists();

If ResourceLoader.CLASSPATH_URL_PREFIX is not wanted in some cases, both prefix + view + suffix and ResourceLoader.CLASSPATH_URL_PREFIX + prefix + view + suffix should be tried.

@ebussieres
Copy link
Member

If you take a look at others TemplateAvailabilityProvider, it's not necessary to add classpath prefix.

Mustache
Thymeleaf

@ebussieres
Copy link
Member

Oh my bad ... so we need to change the default prefix

ebussieres added a commit that referenced this issue Aug 22, 2019
Signed-off-by: Eric Bussieres <[email protected]>
ebussieres added a commit that referenced this issue Aug 22, 2019
Signed-off-by: Eric Bussieres <[email protected]>
@ebussieres ebussieres added this to the 3.1.1 milestone Aug 22, 2019
ebussieres pushed a commit that referenced this issue Aug 22, 2019
Signed-off-by: Eric Bussieres <[email protected]>
ebussieres pushed a commit that referenced this issue Aug 22, 2019
Signed-off-by: Eric Bussieres <[email protected]>
ebussieres added a commit that referenced this issue Aug 22, 2019
@ebussieres
Copy link
Member

Gonna be fixed in next version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants