private void render(Object obj, StringBuilder result, boolean last) {
        index = 0;
        while(scanNextTag()) {
            copyPrefixTo(result);
            index += 2;
            if (isLoopTag()) {
                index++;
                String tagName = readTagName();
                Template body = extractLoopBody(tagName);
                List<?> values = (List<?>) readTagValue(tagName, obj, last);
                int lastIndex = values.size() - 1;
                for (int i = 0; i < values.size(); i++) {
                    body.render(values.get(i), result, i == lastIndex);
                }
            } else {
                String tagName = readTagName();
                result.append(readTagValue(tagName, obj, false));
            }
        }
        copySuffixTo(result);
    }
A single class templating library for doing runtime code-gen.

Not Threadsafe.
jctools-channels/src/main/java/org/jctools/util/Template.java