Add classpath-based template provider to template context factory.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 12:11:27 +0000 (14:11 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 12:11:27 +0000 (14:11 +0200)
src/main/java/net/pterodactylus/demoscenemusic/core/TemplateServlet.java

index 9cfd7f5..1b1ce58 100644 (file)
@@ -41,6 +41,7 @@ import net.pterodactylus.demoscenemusic.data.Artist;
 import net.pterodactylus.demoscenemusic.page.ServletRequest;
 import net.pterodactylus.util.io.Closer;
 import net.pterodactylus.util.io.StreamCopier;
+import net.pterodactylus.util.template.ClassPathTemplateProvider;
 import net.pterodactylus.util.template.CollectionSortFilter;
 import net.pterodactylus.util.template.HtmlFilter;
 import net.pterodactylus.util.template.ReflectionAccessor;
@@ -92,6 +93,8 @@ public class TemplateServlet extends HttpServlet {
                templateContextFactory.addTemplateObject("core", core);
                templateContextFactory.addTemplateObject("dataManager", core.getDataManager());
 
+               templateContextFactory.addProvider(new ClassPathTemplateProvider(getClass(), "/templates/"));
+
                for (@SuppressWarnings("rawtypes")
                Enumeration parameterNames = config.getInitParameterNames(); parameterNames.hasMoreElements();) {
                        String pageName = (String) parameterNames.nextElement();