Browse Source

Support configuration of defaultValue and emptyStringIsFalse

This commit adds support for configuring defaultValue and
emptyStringIsFalse to MustacheCompilerFactoryBean.

Closes gh-4057
pull/4077/head
mackeprm 10 years ago committed by Andy Wilkinson
parent
commit
942da8bdd3
  1. 18
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheCompilerFactoryBean.java

18
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheCompilerFactoryBean.java

@ -48,6 +48,10 @@ public class MustacheCompilerFactoryBean implements FactoryBean<Mustache.Compile @@ -48,6 +48,10 @@ public class MustacheCompilerFactoryBean implements FactoryBean<Mustache.Compile
private Compiler compiler;
private String defaultValue;
private Boolean emptyStringIsFalse;
public void setDelims(String delims) {
this.delims = delims;
}
@ -68,6 +72,14 @@ public class MustacheCompilerFactoryBean implements FactoryBean<Mustache.Compile @@ -68,6 +72,14 @@ public class MustacheCompilerFactoryBean implements FactoryBean<Mustache.Compile
this.collector = collector;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public void setEmptyStringIsFalse(Boolean emptyStringIsFalse) {
this.emptyStringIsFalse = emptyStringIsFalse;
}
@Override
public Mustache.Compiler getObject() throws Exception {
this.compiler = Mustache.compiler();
@ -86,6 +98,12 @@ public class MustacheCompilerFactoryBean implements FactoryBean<Mustache.Compile @@ -86,6 +98,12 @@ public class MustacheCompilerFactoryBean implements FactoryBean<Mustache.Compile
if (this.collector != null) {
this.compiler = this.compiler.withCollector(this.collector);
}
if (this.defaultValue != null) {
this.compiler = this.compiler.defaultValue(this.defaultValue);
}
if (this.emptyStringIsFalse != null) {
this.compiler = this.compiler.emptyStringIsFalse(this.emptyStringIsFalse);
}
return this.compiler;
}

Loading…
Cancel
Save