--- /dev/null
+/*
+ * Copyright (C) 2001, 2002 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+
+package mir.generator.tal;
+
+import java.io.PrintWriter;
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import mir.generator.tal.interfaces.TALLogger;
+import mir.generator.tal.template.Template;
+import mir.generator.tal.template.TemplateLibrary;
+import mir.generator.tal.template.TemplateProcessingException;
+import mir.generator.tal.template.CoreTemplateNodeLibrary;
+import mir.generator.tal.template.MacroTemplateNodeLibrary;
+
+public class TALTest {
+ public static void main(String args[]) {
+ try {
+ final SimpleTemplateNodeLibraryRegistry registry = new SimpleTemplateNodeLibraryRegistry();
+
+ registry.registerTemplateNodeLibrary("tal", "http://xml.zope.org/namespaces/tal",
+ new CoreTemplateNodeLibrary("tal", "http://xml.zope.org/namespaces/tal"));
+ registry.registerTemplateNodeLibrary("metal", "http://xml.zope.org/namespaces/metal",
+ new MacroTemplateNodeLibrary("metal", "http://xml.zope.org/namespaces/metal"));
+
+ TemplateLibrary library = new TemplateLibrary() {
+ public Template lookupTemplate(String aTemplateName) throws TemplateProcessingException {
+ try {
+ TALTemplateParser parser = new TALTemplateParser(registry);
+
+ if (aTemplateName.equals("a")) {
+ return parser.parse("<test tal:on-error='${exception.message}'><bkla><font tal:content='${sdf'></bkla><td><b><font>bla</font></b></td></font>" +
+ "<test2 metal:use-macro=\"b#testmacro\"></test2><test3 a='b' tal:attributes='c a:${tagattributes.a}'> </test3> " +
+ "<test4 tal:content='the content was ${tagcontent}'>bla <b>die</b> bla ></test4><a width='100%'/>" +
+ "<test5 tal:bla=a><tal:bla/></test5> </test>", new MirExpressionParser());
+ }
+ else {
+ return parser.parse("<test3><test4 metal:define-macro=\"testmacro\">hoi</test4><test3>", new MirExpressionParser());
+ }
+ }
+ catch (Throwable t) {
+ t.printStackTrace();
+ System.out.println(t.toString());
+ return null;
+ }
+ }
+ };
+
+ Map test = new HashMap();
+
+ Template template = library.lookupTemplate("a");
+
+ PrintWriter p = new PrintWriter(System.out);
+
+ template.process(new HashMap(), p, new TALLogger.TALSystemOutLogger(), library);
+
+ p.close();
+
+ }
+ catch (Throwable t) {
+ System.out.println("Exception: " + t.toString());
+ t.printStackTrace(System.out);
+ }
+ }
+ public static void main2(String args[]) {
+ try {
+ TALTemplateEngine engine = new TALTemplateEngine(
+ new MirExpressionParser(), new File("m:/romania/mir/etc/producer/"));
+
+ Map test = new HashMap();
+ test.put("name", "zapata");
+
+ Template template = engine.loadTemplate("indy-ro-txt.html");
+
+ PrintWriter p = new PrintWriter(System.out);
+
+ template.process(new Object(), p, new TALLogger.TALSystemOutLogger(), engine);
+
+ p.close();
+
+ }
+ catch (Throwable t) {
+ System.out.println("Exception: " + t.toString());
+ t.printStackTrace(System.out);
+ }
+ }
+}
\ No newline at end of file