projects
/
org.ibex.xt-crawshaw.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
59e1d7b
)
template inclusion now works
author
crawshaw
<crawshaw@ibex.org>
Thu, 25 Nov 2004 08:21:39 +0000
(08:21 +0000)
committer
crawshaw
<crawshaw@ibex.org>
Thu, 25 Nov 2004 08:21:39 +0000
(08:21 +0000)
darcs-hash:
20041125082139
-2eb37-
86b4647e53df0993183f4527ba957ec68419931e
.gz
src/java/org/ibex/xt/Template.java
patch
|
blob
|
history
diff --git
a/src/java/org/ibex/xt/Template.java
b/src/java/org/ibex/xt/Template.java
index
ac29e8f
..
4ab16d6
100644
(file)
--- a/
src/java/org/ibex/xt/Template.java
+++ b/
src/java/org/ibex/xt/Template.java
@@
-41,7
+41,9
@@
public class Template extends JSElement {
//throw new JSElement.Exn("Unknown XT library: "+uri);
} else if (uri.startsWith("local:")) {
//throw new JSElement.Exn("Unknown XT library: "+uri);
} else if (uri.startsWith("local:")) {
- Template t = parse(s.getLocalPath() + uri.substring(6), s);
+ // merge a new template into this tree
+ String path = uri.substring(6) + e.getLocalName() + ".xt";
+ Template t = parse(s.getLocalPath() + path, s);
List c = e.getChildren();
if (c.size() > 0) {
List c = e.getChildren();
if (c.size() > 0) {
@@
-55,8
+57,15
@@
public class Template extends JSElement {
e.getChildren().clear();
}
e.getChildren().clear();
}
- // merge original attributes with replacement template
- e = new JSElement.Merge(t, e);
+ XML.Element merged = new JSElement.Merge(t, e);
+
+ // remap the parent of the original element
+ if (e.getParent() != null) {
+ List ch = e.getParent().getChildren();
+ ch.set(ch.indexOf(e), merged);
+ }
+
+ return wrap(merged, s);
}
XML.Attributes a = e.getAttributes();
}
XML.Attributes a = e.getAttributes();
@@
-78,12
+87,14
@@
public class Template extends JSElement {
}
/** Returns the first Template.Children child found. */
}
/** Returns the first Template.Children child found. */
- private static Template.Children findPlaceholder(XML.Element e) {
- if (e instanceof Template.Children) return (Template.Children)e;
+ private static XML.Element findPlaceholder(XML.Element e) {
+ if ("http://xt.ibex.org/".equals(e.getUri()) && "children".equals(e.getLocalName()))
+ return e;
+
List c = e.getChildren();
for (int i=0; i < c.size(); i++) {
if (!(c.get(i) instanceof XML.Element)) continue;
List c = e.getChildren();
for (int i=0; i < c.size(); i++) {
if (!(c.get(i) instanceof XML.Element)) continue;
- Template.Children ret = findPlaceholder((XML.Element)c.get(i));
+ XML.Element ret = findPlaceholder((XML.Element)c.get(i));
if (ret != null) return ret;
}
return null;
if (ret != null) return ret;
}
return null;