X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2FTemplate.java;h=2f3e2acef89baddfa7cbe2619bb22bcead772540;hb=bb26c9c5308bb6d0ec5554a357fc86085139ccb3;hp=154de72b70027cf17158b285ad00c272f37310c6;hpb=4abd3e305d0b87f37d5969016b86ba53574a3210;p=org.ibex.core.git diff --git a/src/org/ibex/Template.java b/src/org/ibex/Template.java index 154de72..2f3e2ac 100644 --- a/src/org/ibex/Template.java +++ b/src/org/ibex/Template.java @@ -32,7 +32,9 @@ public class Template { private Vec children = new Vec(); ///< during XML parsing, this holds the list of currently-parsed children; null otherwise private JS script = null; ///< the script on this node Template prev; + Template prev2; JSScope staticScope = null; ///< the scope in which the static block is executed + JS staticObject = null; // Only used during parsing ///////////////////////////////////////////////////////////////// @@ -75,12 +77,14 @@ public class Template { private void apply(Box b, PerInstantiationScope parentPis) throws JSExn, IOException { if (prev != null) prev.apply(b, null); + if (prev2 != null) prev2.apply(b, null); // FIXME this dollar stuff is all wrong if (id != null) parentPis.putDollar(id, b); - PerInstantiationScope pis = new PerInstantiationScope(b, ibex, parentPis, staticScope); + PerInstantiationScope pis = new PerInstantiationScope(b, ibex, parentPis, staticObject); for(int i=0; i 0 && val.charAt(0) == '.') val = val.substring(1); t.urivals[ii] = val; @@ -226,11 +234,10 @@ public class Template { // process attributes into Vecs, dealing with any XML Namespaces in the process ATTR: for (int i=0; i < c.getAttrLen(); i++) { - //#switch(c.getAttrKey(i)) - case "id": + if (c.getAttrKey(i).equals("id")) { t.id = c.getAttrVal(i).toString().intern(); continue ATTR; - //#end + } // treat value starting with '.' as resource reference String uri = c.getAttrUri(i); if (!uri.equals("")) uri = '.' + uri; @@ -288,6 +295,7 @@ public class Template { nodeStack.setSize(nodeStack.size() - 1); t.children.addElement(oldt); int oldt_lines = getLine() - oldt.startLine; + if (t.content == null) t.content = new StringBuffer(); for (int i=0; oldt_lines > i; i++) t.content.append('\n'); } } @@ -320,13 +328,13 @@ public class Template { private static class PerInstantiationScope extends JSScope { Ibex ibex = null; PerInstantiationScope parentBoxPis = null; - JSScope myStatic = null; + JS myStatic = null; void putDollar(String key, Box target) throws JSExn { if (parentBoxPis != null) parentBoxPis.putDollar(key, target); declare("$" + key); put("$" + key, target); } - public PerInstantiationScope(JSScope parentScope, Ibex ibex, PerInstantiationScope parentBoxPis, JSScope myStatic) { + public PerInstantiationScope(JSScope parentScope, Ibex ibex, PerInstantiationScope parentBoxPis, JS myStatic) { super(parentScope); this.parentBoxPis = parentBoxPis; this.ibex = ibex;