Search in sources :

Example 1 with ThymeleafHttpServletResponseAdapter

use of ratpack.thymeleaf.internal.ThymeleafHttpServletResponseAdapter in project ratpack by ratpack.

the class Template method thymeleafTemplate.

public static Template thymeleafTemplate(Map<String, ?> model, String name, String contentType, IFragmentSpec fragmentSpec) {
    HttpServletRequest request = new ThymeleafHttpServletRequestAdapter();
    HttpServletResponse response = new ThymeleafHttpServletResponseAdapter();
    ServletContext servletContext = new ThymeleafServletContextAdapter();
    WebContext context = new WebContext(request, response, servletContext);
    if (model != null) {
        context.setVariables(model);
    }
    return new Template(name, context, contentType, fragmentSpec);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ThymeleafServletContextAdapter(ratpack.thymeleaf.internal.ThymeleafServletContextAdapter) ThymeleafHttpServletResponseAdapter(ratpack.thymeleaf.internal.ThymeleafHttpServletResponseAdapter) WebContext(org.thymeleaf.context.WebContext) HttpServletResponse(javax.servlet.http.HttpServletResponse) ServletContext(javax.servlet.ServletContext) ThymeleafHttpServletRequestAdapter(ratpack.thymeleaf.internal.ThymeleafHttpServletRequestAdapter)

Aggregations

ServletContext (javax.servlet.ServletContext)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 WebContext (org.thymeleaf.context.WebContext)1 ThymeleafHttpServletRequestAdapter (ratpack.thymeleaf.internal.ThymeleafHttpServletRequestAdapter)1 ThymeleafHttpServletResponseAdapter (ratpack.thymeleaf.internal.ThymeleafHttpServletResponseAdapter)1 ThymeleafServletContextAdapter (ratpack.thymeleaf.internal.ThymeleafServletContextAdapter)1