Commit 9b121dcb authored by Dave Syer's avatar Dave Syer

Make MustacheViewResolver extend AbstractTemplateViewResolver

The Mustache support should still be usable outside a web application
because the properties only use web stuff in that context and don't
have any field or method signatures that depend on web.

Fixes gh-5626
parent 69b08291
......@@ -113,11 +113,7 @@ public class MustacheAutoConfiguration {
@ConditionalOnMissingBean(MustacheViewResolver.class)
public MustacheViewResolver mustacheViewResolver(Compiler mustacheCompiler) {
MustacheViewResolver resolver = new MustacheViewResolver();
resolver.setPrefix(this.mustache.getPrefix());
resolver.setSuffix(this.mustache.getSuffix());
resolver.setCache(this.mustache.isCache());
resolver.setViewNames(this.mustache.getViewNames());
resolver.setContentType(this.mustache.getContentType().toString());
this.mustache.applyToViewResolver(resolver);
resolver.setCharset(this.mustache.getCharsetName());
resolver.setCompiler(mustacheCompiler);
resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 10);
......
......@@ -16,7 +16,7 @@
package org.springframework.boot.autoconfigure.mustache;
import org.springframework.boot.autoconfigure.template.AbstractViewResolverProperties;
import org.springframework.boot.autoconfigure.template.AbstractTemplateViewResolverProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
......@@ -26,7 +26,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @since 1.2.2
*/
@ConfigurationProperties(prefix = "spring.mustache")
public class MustacheProperties extends AbstractViewResolverProperties {
public class MustacheProperties extends AbstractTemplateViewResolverProperties {
public static final String DEFAULT_PREFIX = "classpath:/templates/";
......@@ -42,18 +42,26 @@ public class MustacheProperties extends AbstractViewResolverProperties {
*/
private String suffix = DEFAULT_SUFFIX;
public MustacheProperties() {
super(DEFAULT_PREFIX, DEFAULT_SUFFIX);
}
@Override
public String getPrefix() {
return this.prefix;
}
@Override
public void setPrefix(String prefix) {
this.prefix = prefix;
}
@Override
public String getSuffix() {
return this.suffix;
}
@Override
public void setSuffix(String suffix) {
this.suffix = suffix;
}
......
......@@ -29,7 +29,7 @@ import org.springframework.beans.propertyeditors.LocaleEditor;
import org.springframework.core.io.Resource;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.view.UrlBasedViewResolver;
import org.springframework.web.servlet.view.AbstractTemplateViewResolver;
/**
* Spring MVC {@link ViewResolver} for Mustache.
......@@ -39,7 +39,7 @@ import org.springframework.web.servlet.view.UrlBasedViewResolver;
* @author Phillip Webb
* @since 1.2.2
*/
public class MustacheViewResolver extends UrlBasedViewResolver {
public class MustacheViewResolver extends AbstractTemplateViewResolver {
private Compiler compiler = Mustache.compiler();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment