@@ -0,0 +1,1384 @@
+package net.champemont.jean.hogancompile.helper;%0D%0A%0D%0Aimport java.io.File;%0D%0Aimport java.io.FileReader;%0D%0Aimport java.io.IOException;%0D%0Aimport java.io.Reader;%0D%0Aimport java.net.URISyntaxException;%0D%0A%0D%0Aimport org.mozilla.javascript.Context;%0D%0Aimport org.mozilla.javascript.Scriptable;%0D%0A%0D%0Apublic class HoganTemplateCompileHelper %7B%0D%0A%09%0D%0A%09private static String HOGANJS_FILENAME = %22hogan-2.0.0.js%22;%0D%0A%09%0D%0A%09private static String COMPILE_CMD = %22var result = Hogan.compile(template, %7BasString: true%7D);%22;%0D%0A%09%0D%0A%09public static String compileHoganTemplate(String template, String templateName) throws IOException %7B%0D%0A%09%09String result = null;%0D%0A%09%09Context cx = Context.enter();%0D%0A%09%09Scriptable scope = cx.initStandardObjects();%0D%0A%09%09Reader hoganJS;%0D%0A%09%09try %7B%0D%0A%09%09%09hoganJS = new FileReader(new File(HoganTemplateCompileHelper.class.getClassLoader().getResource(HOGANJS_FILENAME).toURI()));%0D%0A%09%09%7D catch (URISyntaxException e) %7B%0D%0A%09%09%09throw new IOException(HOGANJS_FILENAME + %22 was not found on classpath. Aborting%22);%0D%0A%09%09%7D%0D%0A%09%09cx.evaluateReader(scope, hoganJS, HOGANJS_FILENAME, 1, null);%0D%0A%09%09scope.put(%22template%22, scope, template);%0D%0A%09%09cx.evaluateString(scope, COMPILE_CMD, %22COMPILE_CMD%22, 1, null);%0D%0A%09%09%0D%0A%09%09result = %22templates.%22 + templateName + %22 = new Hogan.Template(%22 + (String) scope.get(%22result%22, scope) + %22);%22;%0D%0A%09%09return result;%0D%0A%09%7D%0D%0A%09%0D%0A%09public static String getTemplateHeader() %7B%0D%0A%09%09return %22var templates = %7B%7D;%22;%0D%0A%09%7D%0D%0A%7D%0D%0A

Add main helper to compile Hogan.js templates