X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Foutput%2Ftemplate%2FTemplate.java;h=dfb7b46382f92c8b36e9a207fb28687016bf9eb5;hb=47aa7641e6b1ce74178c559fbad67bc9fb012a88;hp=e80885710959c0ce23ba67c02350b4f94a6d39e7;hpb=0280098c5dd5b6c0ce339c82d3478ad9452a43b9;p=gigi.git diff --git a/src/org/cacert/gigi/output/template/Template.java b/src/org/cacert/gigi/output/template/Template.java index e8088571..dfb7b463 100644 --- a/src/org/cacert/gigi/output/template/Template.java +++ b/src/org/cacert/gigi/output/template/Template.java @@ -27,7 +27,7 @@ import org.cacert.gigi.util.HTMLEncoder; */ public class Template implements Outputable { - private static class ParseResult { + protected static class ParseResult { TemplateBlock block; @@ -106,7 +106,11 @@ public class Template implements Outputable { } } - private ParseResult parse(Reader r) throws IOException { + protected ParseResult parse(Reader r) throws IOException { + return parseContent(r); + } + + protected ParseResult parseContent(Reader r) throws IOException { LinkedList splitted = new LinkedList(); LinkedList commands = new LinkedList(); StringBuffer buf = new StringBuffer(); @@ -119,6 +123,9 @@ public class Template implements Outputable { break outer; } buf.append((char) ch); + if (endsWith(buf, "\\\n")) { + buf.delete(buf.length() - 2, buf.length()); + } } buf.delete(buf.length() - 2, buf.length()); splitted.add(buf.toString()); @@ -137,10 +144,10 @@ public class Template implements Outputable { if (m.matches()) { String type = m.group(1); String variable = m.group(2); - ParseResult body = parse(r); + ParseResult body = parseContent(r); if (type.equals("if")) { if ("else".equals(body.getEndType())) { - commands.add(new IfStatement(variable, body.getBlock("else"), parse(r).getBlock("}"))); + commands.add(new IfStatement(variable, body.getBlock("else"), parseContent(r).getBlock("}"))); } else { commands.add(new IfStatement(variable, body.getBlock("}"))); } @@ -186,6 +193,11 @@ public class Template implements Outputable { @Override public void output(PrintWriter out, Language l, Map vars) { + tryReload(); + data.output(out, l, vars); + } + + protected void tryReload() { if (source != null && lastLoaded < source.lastModified()) { try { System.out.println("Reloading template.... " + source); @@ -197,10 +209,12 @@ public class Template implements Outputable { e.printStackTrace(); } } - data.output(out, l, vars); } protected static void outputVar(PrintWriter out, Language l, Map vars, String varname, boolean unescaped) { + if (vars.containsKey(Outputable.OUT_KEY_PLAIN)) { + unescaped = true; + } Object s = vars.get(varname); if (s == null) {