@Override
public void process(final ProcessContext context, final TemplateModel<MustacheContext> mustacheTemplateModel) {
// Nothing to do for now
// Visit the mustache
MustacheFactory factory = new DefaultMustacheFactory() {
@Override
public Reader getReader(String resourceName) {
Path.Relative partialPath = (Path.Relative)Path.parse(resourceName);
Timestamped<Resource> partial = context.resolveResource(partialPath);
if (partial != null) {
return new StringReader(partial.getObject().getCharSequence().toString());
} else {
return null;
}
}
public MustacheVisitor createMustacheVisitor() {
return new DefaultMustacheVisitor(this) {
@Override
public void pragma(TemplateContext templateContext, String pragma, String args) {
if ("param".equals(pragma)) {
mustacheTemplateModel.addParameter(args);
} else {
super.pragma(templateContext, pragma, args);
}
}
};
}
};
// Does the name count ?
factory.compile(new StringReader(mustacheTemplateModel.getModel().source), mustacheTemplateModel.getPath().getSimpleName());
}