I recently picked Spring framework for my university project on Java course, picked Jade4J for my template engine already put the dependancy in pom.xml and installed the package but when i'm calling the Jade4J.render("./index.jade", model);
but I'm getting "./index.jade (File not found)" response. Uppon looking in the github repo there's no particular information how to make configuration class with the directory it will look for templates. I even tried to put the index.jade file everywhere in the project(controller dir, dir where main.java is implemented, resources dir, webapp dir). I'd appreciate any help I'll provide any further information if necessary
Edit 1
Added JadeConfig class to project with the content:
@Bean
public SpringTemplateLoader templateLoader() {
SpringTemplateLoader templateLoader = new SpringTemplateLoader();
templateLoader.setBasePath("/templates/");
templateLoader.setEncoding("UTF-8");
templateLoader.setSuffix(".jade");
return templateLoader;
}
@Bean
public JadeConfiguration jadeConfiguration() {
JadeConfiguration configuration = new JadeConfiguration();
configuration.setCaching(false);
configuration.setTemplateLoader(templateLoader());
return configuration;
}
@Bean
public ViewResolver viewResolver() {
JadeViewResolver viewResolver = new JadeViewResolver();
viewResolver.setConfiguration(jadeConfiguration());
return viewResolver;
}
My index controller has the following function:
@GetMapping(value = "/")
public String greeting() throws IOException {
Map<String, Object> model = new HashMap<String, Object>();
model.put("title", "Index Page");
String html = Jade4J.render("./index.jade", model);
return html;
}
And lastly the template index.jade path is src\main\webapp\templates\index.jade