Use a copy of delims in the parser.
I don't know what madness overcame me when I thought it was a good idea to mutate the compiler's delims during parsing and then restore them.
This commit is contained in:
@@ -288,14 +288,8 @@ public class Mustache
|
|||||||
* Compiles the supplied template into a repeatedly executable intermediate form.
|
* Compiles the supplied template into a repeatedly executable intermediate form.
|
||||||
*/
|
*/
|
||||||
protected static Template compile (Reader source, Compiler compiler) {
|
protected static Template compile (Reader source, Compiler compiler) {
|
||||||
Delims orig = compiler.delims.save();
|
Accumulator accum = new Parser(compiler).parse(source);
|
||||||
try {
|
return new Template(accum.finish(), compiler);
|
||||||
Accumulator accum = new Parser(compiler).parse(source);
|
|
||||||
return new Template(accum.finish(), compiler);
|
|
||||||
} finally {
|
|
||||||
// restore the original delimiters
|
|
||||||
compiler.delims.restore(orig);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Mustache () {} // no instantiateski
|
private Mustache () {} // no instantiateski
|
||||||
@@ -333,7 +327,7 @@ public class Mustache
|
|||||||
|
|
||||||
public Parser (Compiler compiler) {
|
public Parser (Compiler compiler) {
|
||||||
this.accum = new Accumulator(compiler);
|
this.accum = new Accumulator(compiler);
|
||||||
this.delims = compiler.delims;
|
this.delims = compiler.delims.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Accumulator parse (Reader source) {
|
public Accumulator parse (Reader source) {
|
||||||
@@ -516,16 +510,13 @@ public class Mustache
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Delims save () {
|
Delims copy () {
|
||||||
return new Delims().restore(this);
|
Delims d = new Delims();
|
||||||
}
|
d.start1 = start1;
|
||||||
|
d.start2 = start2;
|
||||||
Delims restore (Delims delims) {
|
d.end1 = end1;
|
||||||
this.start1 = delims.start1;
|
d.end2 = end2;
|
||||||
this.start2 = delims.start2;
|
return d;
|
||||||
this.end1 = delims.end1;
|
|
||||||
this.end2 = delims.end2;
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String errmsg (String dtext) {
|
private static String errmsg (String dtext) {
|
||||||
|
|||||||
Reference in New Issue
Block a user