1818import com .github .jknack .handlebars .Decorator ;
1919import com .github .jknack .handlebars .Handlebars ;
2020import com .github .jknack .handlebars .Helper ;
21- import com .github .jknack .handlebars .Template ;
2221import com .github .jknack .handlebars .cache .HighConcurrencyTemplateCache ;
2322import com .github .jknack .handlebars .cache .NullTemplateCache ;
2423import com .github .jknack .handlebars .cache .TemplateCache ;
2524import com .github .jknack .handlebars .io .ClassPathTemplateLoader ;
2625import com .github .jknack .handlebars .io .FileTemplateLoader ;
2726import com .github .jknack .handlebars .io .TemplateLoader ;
28- import io . jooby . Context ;
27+ import com . typesafe . config . Config ;
2928import io .jooby .Environment ;
3029import io .jooby .Extension ;
3130import io .jooby .Jooby ;
3231import io .jooby .MediaType ;
33- import io .jooby .ModelAndView ;
34- import io .jooby .TemplateEngine ;
3532
3633import javax .annotation .Nonnull ;
3734import java .io .File ;
4441import java .nio .file .Files ;
4542import java .nio .file .Path ;
4643import java .nio .file .Paths ;
47-
48- import static java .util .Optional .ofNullable ;
44+ import java .util .Optional ;
4945
5046public class Hbs implements Extension {
5147
@@ -57,7 +53,7 @@ public static class Builder {
5753
5854 private TemplateCache cache ;
5955
60- private String templatePath = "views" ;
56+ private String templatePath ;
6157
6258 public Builder () {
6359 handlebars = new Handlebars ();
@@ -134,7 +130,14 @@ public Builder() {
134130
135131 public @ Nonnull Handlebars build (@ Nonnull Environment env ) {
136132 if (loader == null ) {
137- loader = defaultTemplateLoader (env , templatePath );
133+ Config config = env .getConfig ();
134+ String defaultTemplatePath = config .hasPath ("handlebars.templatePath" )
135+ ? config .getString ("handlebars.templatePath" )
136+ : "views" ;
137+ String templatePath = Optional .ofNullable (this .templatePath )
138+ .orElse (defaultTemplatePath );
139+ setTemplatePath (templatePath );
140+ loader = defaultTemplateLoader (env , this .templatePath );
138141 }
139142 handlebars .with (loader );
140143
0 commit comments