com.github.mustachejava.codes.ValueCode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of compiler Show documentation
Show all versions of compiler Show documentation
Implementation of mustache.js for Java
package com.github.mustachejava.codes;
import com.github.mustachejava.DefaultMustacheFactory;
import com.github.mustachejava.FragmentKey;
import com.github.mustachejava.MustacheException;
import com.github.mustachejava.TemplateContext;
import com.github.mustachejava.util.LatchedWriter;
import com.github.mustachejava.util.Node;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.github.mustachejava.MustacheParser.DEFAULT_EM;
import static com.github.mustachejava.MustacheParser.DEFAULT_SM;
import static com.github.mustachejava.util.NodeValue.value;
/**
* Output a value
*/
public class ValueCode extends DefaultCode {
private final boolean encoded;
private final ExecutorService les;
@Override
public void identity(Writer writer) {
try {
if (name != null) {
writer.write(tc.startChars());
if (!encoded) {
writer.write("{");
}
writer.write(type);
writer.write(name);
if (!encoded) {
writer.write("}");
}
writer.write(tc.endChars());
}
appendText(writer);
} catch (IOException e) {
throw new MustacheException(e);
}
}
public ValueCode(TemplateContext tc, DefaultMustacheFactory df, String variable, boolean encoded) {
super(tc, df, null, variable, "");
this.encoded = encoded;
les = df.getExecutorService();
}
@Override
public Writer execute(Writer writer, final List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy