Add mechism to visit template tags.
This is useful when you want to inspect the structure of the template without executing it.
This commit is contained in:
@@ -149,6 +149,16 @@ public class Template {
|
||||
executeSegs(new Context(context, pctx, 0, false, false), out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Visits the tags in this template (via {@code visitor}) without executing it.
|
||||
* @param visitor the visitor to be called back on each tag in the template.
|
||||
*/
|
||||
public void visit (Mustache.Visitor visitor) {
|
||||
for (Segment seg : _segs) {
|
||||
seg.visit(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
protected Template (Segment[] segs, Mustache.Compiler compiler) {
|
||||
_segs = segs;
|
||||
_compiler = compiler;
|
||||
@@ -367,6 +377,8 @@ public class Template {
|
||||
|
||||
abstract void decompile (Mustache.Delims delims, StringBuilder into);
|
||||
|
||||
abstract void visit (Mustache.Visitor visitor);
|
||||
|
||||
protected static void write (Writer out, String data) {
|
||||
try {
|
||||
out.write(data);
|
||||
|
||||
Reference in New Issue
Block a user