From 73eed012df8d842738f64dc45ce5f13aad788b5e Mon Sep 17 00:00:00 2001
From: ulrich
Date: Wed, 07 Jul 2021 14:52:43 +0000
Subject: [PATCH] Template als Parameter anstelle eines Attributes des HttpContext

---
 src/de/uhilger/httpserver/template/TemplateActor.java |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/de/uhilger/httpserver/template/TemplateActor.java b/src/de/uhilger/httpserver/template/TemplateActor.java
index 87f51e6..336c9dd 100644
--- a/src/de/uhilger/httpserver/template/TemplateActor.java
+++ b/src/de/uhilger/httpserver/template/TemplateActor.java
@@ -45,7 +45,7 @@
   public static final String STR_EMPTY = "";
   public static final String STR_SLASH = "/";
   
-  public static final String ATTR_TEMPLATE = "template";
+  //public static final String ATTR_TEMPLATE = "template";
   
   //public static final String WELCOME_FILE = "index.htmi";
   
@@ -63,19 +63,22 @@
    * @return das ausgefuellte Template
    * @throws IOException 
    */
-  public String render(HttpExchange exchange, Map data) throws IOException {
+  public String render(HttpExchange exchange, Map data, String template) throws IOException {
     MustacheFactory mf;
     Mustache m;
     HttpHelper helper = new HttpHelper();
     Map attributes = exchange.getHttpContext().getAttributes();
     String fileBase = helper.getAttrStr(attributes, FileHandler.ATTR_FILE_BASE, STR_EMPTY);
     File fileRoot = new File(fileBase);    
-    String template = helper.getAttrStr(attributes, ATTR_TEMPLATE, STR_EMPTY);
+    logger.fine("fileRoot: " + fileRoot.getAbsolutePath());
+    //String template = helper.getAttrStr(attributes, ATTR_TEMPLATE, STR_EMPTY);
     File templateFile = new File(fileRoot, template);
     if(templateFile.exists()) {
+      logger.fine("using template " + templateFile.getAbsolutePath());
       mf = new NeonMustacheFactory(fileRoot);
       m = mf.compile(template);
     } else {
+      logger.fine("template " + templateFile.getAbsolutePath() + " not found");
       mf = new NeonMustacheFactory();
       m = mf.compile(template);
     }

--
Gitblit v1.9.3