io.honeybadger.com.github.mustachejava.util.CapturingMustacheVisitor Maven / Gradle / Ivy
package com.github.mustachejava.util;
import com.github.mustachejava.DefaultMustacheFactory;
import com.github.mustachejava.DefaultMustacheVisitor;
import com.github.mustachejava.Mustache;
import com.github.mustachejava.TemplateContext;
import com.github.mustachejava.codes.IterableCode;
import com.github.mustachejava.codes.NotIterableCode;
import com.github.mustachejava.codes.ValueCode;
import java.io.Writer;
import java.util.List;
/**
* Grab a map of values returned from calls
*/
public class CapturingMustacheVisitor extends DefaultMustacheVisitor {
private final Captured captured;
public interface Captured {
void value(String name, String value);
void arrayStart(String name);
void arrayEnd();
void objectStart();
void objectEnd();
}
public CapturingMustacheVisitor(DefaultMustacheFactory cf, Captured captured) {
super(cf);
this.captured = captured;
}
@Override
public void value(TemplateContext tc, String variable, boolean encoded) {
list.add(new ValueCode(tc, df, variable, encoded) {
@Override
public Object get(List