com.github.mustachejava.codes.PartialCode 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.*;
import java.io.IOException;
import java.io.Writer;
import java.util.List;
public class PartialCode extends DefaultCode {
protected final String extension;
protected final String dir;
protected Mustache partial;
protected int recrusionLimit;
protected boolean isRecursive;
protected PartialCode(TemplateContext tc, DefaultMustacheFactory df, Mustache mustache, String type, String variable) {
super(tc, df, mustache, variable, type);
// Use the name of the parent to get the name of the partial
String file = tc.file();
int dotindex = file.lastIndexOf(".");
extension = dotindex == -1 ? "" : file.substring(dotindex);
int slashindex = file.lastIndexOf("/");
dir = file.substring(0, slashindex + 1);
recrusionLimit = df.getRecursionLimit();
}
public PartialCode(TemplateContext tc, DefaultMustacheFactory cf, String variable) {
this(tc, cf, null, ">", variable);
}
@Override
public void identity(Writer writer) {
try {
if (name != null) {
super.tag(writer, type);
}
appendText(writer);
} catch (IOException e) {
throw new MustacheException(e, tc);
}
}
@Override
public Code[] getCodes() {
return partial == null ? null : partial.getCodes();
}
@Override
public void setCodes(Code[] newcodes) {
partial.setCodes(newcodes);
}
@Override
public Writer execute(Writer writer, final List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy