//#end
} else if (uri.startsWith("http://xt.ibex.org/")) {
- //#switch(uri.substring(19))
- case "io": System.out.println("ibex.xt.io not yet implemented"); // TODO
- //#end
- //throw new JSLeaf.Exn("Unknown XT library: "+uri);
+ throw new JSLeaf.Exn("Unknown XT library: "+uri);
} else if (uri.startsWith("local:")) {
// merge a new template into this tree
e.getChildren().clear();
}
- Tree.Element merged = new JSLeaf.Merge(t, e);
+ // merge the attributes of the template and its representative
+ t.setAttributes(new JSLeaf.MergeAttr(e.getAttributes(), t.getAttributes()));
// remap the parent of the original element
if (e.getParent() != null) {
List ch = e.getParent().getChildren();
- ch.set(ch.indexOf(e), merged);
+ ch.set(ch.indexOf(e), t);
}
- return wrap(merged, s);
+ return wrap(t, s);
}
e = new Template.AttributeEval(e);
/** Processes ${...} blocks in attributes, loads applicable
* attributes into the JS scope and processes global attributes. */
public static class AttributeEval extends JSLeaf.Element implements Tree.Attributes {
+ // TODO: hide global attributes from out() function. waiting on util.XMLHelper
protected Tree.Attributes a;
- public AttributeEval(Tree.Element wrapped) { super(wrapped); a = wrapped.getAttributes(); }
-
- public Tree.Attributes getAttributes() { return this; }
+ public AttributeEval(Tree.Element wrapped) {
+ super(wrapped);
+ a = wrapped.getAttributes();
+ wrapped.setAttributes(this);
+ }
public int getIndex(String q) { return a.getIndex(q); }
public int getIndex(String u, String k) { return a.getIndex(u, k); }
case "declare":
Object d = eval(a.getVal(i));
if (!(d instanceof String)) throw new JSLeaf.Exn(
- "attribute "+getPrefix()+":declare can only contain a "+
+ "attribute '"+getPrefix()+":declare' can only contain a "+
"space seperated list of variable names to declare.");
StringTokenizer st = new StringTokenizer((String)d, " ");
while (st.hasMoreTokens()) scope().declare(st.nextToken());