Java源码示例:com.github.mustachejava.MustacheResolver
示例1
private void init()
{
String templatePath = _config.get("view.mustache.templates",
"classpath:/templates");
MustacheResolver resolver;
if (templatePath.startsWith("classpath:")) {
String root = templatePath.substring("classpath:".length());
resolver = new ClasspathResolver(root);
//ClassLoader loader = Thread.currentThread().getContextClassLoader();
//resolver = new MustacheResolverImpl(loader, root);
}
else {
resolver = new DefaultResolver(templatePath);
}
MustacheFactory factory = new DefaultMustacheFactory(resolver);
_factory = factory;
}
示例2
protected MustacheResolver mustacheResolver(final ResourceLoader templateLoader) {
return name -> {
try {
byte[] bytes = templateLoader.load(name);
U.must(bytes != null, "The Mustache.java template '%s' doesn't exist!", name);
return new StringReader(new String(bytes));
} catch (Exception e) {
throw U.rte(e);
}
};
}
示例3
public StrictMustacheFactory(MustacheResolver mustacheResolver) {
super(mustacheResolver);
}