Closed mhulse closed 5 years ago
This works:
build.gradle
:repositories {
mavenCentral()
maven {
url 'http://dl.bintray.com/jtwig/maven'
}
}
dependencies {
...
compile 'org.jtwig:jtwig-core:5.87.0.RELEASE'
...
}
TemplateUtil.java
// https://github.com/perwendel/spark-template-engines/blob/f4a958f3896151a7d4ee0e1baa22093169acbc54/spark-template-jtwig/src/main/java/spark/template/jtwig/JtwigTemplateEngine.java
import com.foo.baz.plugins.JtwigTemplateEngine;
...
public static String render(String templatePath, Request request, Response response, Map<String, Object> model) {
model = (model != null) ? model : new HashMap<>();
...
return new JtwigTemplateEngine().render(new ModelAndView(model, templatePath));
}
Main.java
get("forgot-password/", (request, response) -> TemplateUtil.render(request,"foo/forgot-password.twig"));
And that did the trick.
My JtwigTemplateExample.java:
build.gradle:
Can anyone help me to get this working? I'm pretty new to java, so be kind. 😄