Inheritance support #120

Turn on inheritance tests. Some whitespace issues.

Recursion working but multi standalone broken

Make inheritance pass spec tests
This commit is contained in:
Adam Gent
2023-11-28 16:30:42 -05:00
parent 92c1222d80
commit a065543327
9 changed files with 424 additions and 88 deletions
@@ -11,6 +11,8 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import com.samskivert.mustache.Mustache.BlockSegment;
/**
* Represents a compiled template. Templates are executed with a <em>context</em> to generate
* output. The context can be any tree of objects. Variables are resolved against the context.
@@ -165,7 +167,7 @@ public class Template {
_fcache = compiler.collector.createFetcherCache();
}
protected Template indent(String indent) {
protected Template indent (String indent) {
// What we want to do here is rebuild this partial template but indented.
// If identing does not change anything we return the original template.
if (indent.equals("")) {
@@ -178,6 +180,17 @@ public class Template {
return new Template(copySegs, _compiler);
}
protected Template replaceBlocks (Map<String, BlockSegment> blocks) {
if (blocks.isEmpty()) {
return this;
}
Segment[] copySegs = Mustache.replaceBlockSegs(_segs, blocks);
if (copySegs == _segs) {
return this;
}
return new Template(copySegs, _compiler);
}
protected void executeSegs (Context ctx, Writer out) throws MustacheException {
for (Segment seg : _segs) {
seg.execute(this, ctx, out);