- public static Template getTemplate(Res r) {
- try {
- r = r.addExtension(".xwt");
- if (r.t != null) return r.t;
- r.t = new Template(r);
- try { new TemplateHelper().parseit(r.getInputStream(), r.t); }
- catch (FileNotFoundException e) { Log.log(Template.class, "template not found: "+r); }
- return r.t;
- } catch (Exception e) {
- if (Log.on) Log.log(r.t == null ? "null" : r.t.fileName, e);
- return null;
- }
- }
-
- public static Res resolveStringToResource(String str, XWT xwt, boolean permitAbsolute) {
- // URL
- if (str.indexOf("://") != -1) {
- if (permitAbsolute) return (Res)xwt.callMethod("res.url", str, null, null, null, 1);
- Log.log(Template.class, "absolute URL " + str + " not permitted here");
- return null;
- }
-
- // root-relative
- Res ret = xwt.rr;
- while(str.indexOf('.') != -1) {
- String path = str.substring(0, str.indexOf('.'));
- str = str.substring(str.indexOf('.') + 1);
- ret = (Res)ret.get(path);
- }
- ret = (Res)ret.get(str);
- return ret;
- }
-
+ // for non-root nodes
+ private Template(Template t, int startLine) { prev = t; this.xwt = t.xwt; this.startLine = startLine; }
+ private Template(XWT xwt) { this.xwt = xwt; }
+