Import common macros from central locatation

git-svn-id: https://svn.libreccm.org/ccm/trunk@5825 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2019-02-07 16:05:11 +00:00
parent 4452fb6fa6
commit 3c0720078a
1 changed files with 15 additions and 3 deletions

View File

@ -10,6 +10,9 @@ import com.arsdigita.xml.Document;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
import freemarker.cache.MultiTemplateLoader;
import freemarker.cache.TemplateLoader;
import freemarker.cache.WebappTemplateLoader;
import freemarker.ext.dom.NodeModel; import freemarker.ext.dom.NodeModel;
import freemarker.template.Configuration; import freemarker.template.Configuration;
import freemarker.template.Template; import freemarker.template.Template;
@ -165,8 +168,17 @@ public class FreeMarkerPresentationManager implements PresentationManager {
final Configuration configuration = new Configuration( final Configuration configuration = new Configuration(
Configuration.VERSION_2_3_28); Configuration.VERSION_2_3_28);
configuration.setServletContextForTemplateLoading(servletContext, final WebappTemplateLoader themeTemplateLoader
themePath); = new WebappTemplateLoader(servletContext,
themePath);
final WebappTemplateLoader macrosLoader = new WebappTemplateLoader(
servletContext,
"/themes/freemarker");
final MultiTemplateLoader templateLoader = new MultiTemplateLoader(
new TemplateLoader[]{themeTemplateLoader, macrosLoader});
// configuration.setServletContextForTemplateLoading(servletContext,
// themePath);
configuration.setTemplateLoader(templateLoader);
configuration.setDefaultEncoding("UTF-8"); configuration.setDefaultEncoding("UTF-8");
final Map<String, Object> data = new HashMap<>(); final Map<String, Object> data = new HashMap<>();
@ -239,7 +251,7 @@ public class FreeMarkerPresentationManager implements PresentationManager {
// .append(template.toString()) // .append(template.toString())
// .append("\n"); // .append("\n");
// } // }
} catch (IOException | TemplateException ex) { } catch (IOException | TemplateException ex) {
throw new UncheckedWrapperException(ex); throw new UncheckedWrapperException(ex);
} }