@@ -0,0 +1,2242 @@
+package ab.liferay.spring.mvc.thymeleaf.angular.core.base.service;%0A%0Aimport com.liferay.portal.util.PortalUtil;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.stereotype.Service;%0Aimport org.springframework.ui.ModelMap;%0Aimport org.springframework.web.servlet.ModelAndView;%0Aimport org.thymeleaf.context.IContext;%0Aimport org.thymeleaf.context.WebContext;%0Aimport org.thymeleaf.spring4.SpringTemplateEngine;%0Aimport org.thymeleaf.spring4.view.AjaxThymeleafView;%0Aimport org.thymeleaf.spring4.view.ThymeleafView;%0Aimport org.thymeleaf.standard.fragment.StandardDOMSelectorFragmentSpec;%0A%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0A@Service%0Apublic class RenderServiceImpl implements RenderService %7B%0A%0A    private static final java.lang.String FRAGMENT_SEPARATOR = %22::%22;%0A    private final PortletService portletService;%0A    private final SpringTemplateEngine templateEngine;%0A%0A    @Autowired%0A    public RenderServiceImpl(PortletService portletService, SpringTemplateEngine templateEngine) %7B%0A        this.portletService = portletService;%0A        this.templateEngine = templateEngine;%0A    %7D%0A%0A    @Override%0A    public String renderTemplate(ModelAndView modelAndView) %7B%0A%0A        ThymeleafView view = new AjaxThymeleafView();%0A        String%5B%5D views = modelAndView.getViewName().split(FRAGMENT_SEPARATOR);%0A        view.setTemplateName(views%5B0%5D.trim());%0A        if (views.length == 2) %7B%0A            view.setFragmentSpec(new StandardDOMSelectorFragmentSpec(views%5B1%5D.trim()));%0A        %7D%0A%0A        HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(portletService.getPortletRequest());%0A        HttpServletResponse httpServletResponse = PortalUtil.getHttpServletResponse(portletService.getPortletResponse());%0A%0A        IContext iContext = new WebContext(httpServletRequest, httpServletResponse, httpServletRequest.getServletContext(), portletService.getLocale(), modelAndView.getModel());%0A        return templateEngine.process(view.getTemplateName(), iContext, view.getFragmentSpec());%0A    %7D%0A%0A    @Override%0A    public String renderTemplate(String viewName, ModelMap modelMap) %7B%0A        return renderTemplate(new ModelAndView(viewName, modelMap));%0A    %7D%0A%7D

add service to render multiple thymeleaf templates in request and response the contents as json