solved the bug that caused problems when an article's title contained "'s
[mir.git] / source / mir / misc / HTMLTemplateProcessor.java
index 56d0b30..3f014cc 100755 (executable)
@@ -32,6 +32,8 @@
 package mir.misc;
 
 import freemarker.template.*;
+import mir.util.*;
+import mir.generator.*;
 import mir.entity.Entity;
 import mir.entity.EntityList;
 import mir.storage.StorageObjectException;
@@ -247,6 +249,17 @@ public final class HTMLTemplateProcessor {
         // this conform to updated freemarker syntax
         configHash.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace());
 
+        SimpleHash utilityHash = new SimpleHash();
+        try {
+          utilityHash.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace());
+          utilityHash.put("encodeURI", FreemarkerGenerator.makeAdapter(new GeneratorHTMLFunctions.encodeURIGeneratorFunction()));
+          utilityHash.put("encodeHTML", FreemarkerGenerator.makeAdapter(new GeneratorHTMLFunctions.encodeHTMLGeneratorFunction()));
+        }
+        catch (Throwable t) {
+          throw new HTMLParseException(t.getMessage());
+        }
+
+
         SimpleHash outPutHash = new SimpleHash();
 
         if (extra != null) {
@@ -260,6 +273,7 @@ public final class HTMLTemplateProcessor {
         }
         outPutHash.put("data", tmr);
         outPutHash.put("config", configHash);
+        outPutHash.put("utility", utilityHash);
 
         MessageResources messages = MessageResources.getMessageResources(bundles);
         outPutHash.put("lang", new MessageMethodModel(locale, messages));