com.github.mustachejava.MustacheVisitor Java Examples

The following examples show how to use com.github.mustachejava.MustacheVisitor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MustacheHelper.java    From helidon-build-tools with Apache License 2.0 6 votes vote down vote up
@Override
public MustacheVisitor createMustacheVisitor() {
    return new DefaultMustacheVisitor(this) {
        @Override
        public void value(TemplateContext tc, String variable, boolean encoded) {
            list.add(new ValueCode(tc, df, variable, encoded) {
                @Override
                public Writer execute(Writer writer, List<Object> scopes) {
                    try {
                        final Object object = get(scopes);
                        if (object instanceof NotEncoded) {
                            writer.write(oh.stringify(object));
                            return appendText(run(writer, scopes));
                        } else {
                            return super.execute(writer, scopes);
                        }
                    } catch (Exception e) {
                        throw new MustacheException("Failed to get value for " + name, e, tc);
                    }
                }
            });
        }
    };
}
 
Example #2
Source File: CustomMustacheFactory.java    From elasticsearch-learning-to-rank with Apache License 2.0 4 votes vote down vote up
@Override
public MustacheVisitor createMustacheVisitor() {
    return new CustomMustacheVisitor(this);
}
 
Example #3
Source File: StrictMustacheFactory.java    From spoofax with Apache License 2.0 4 votes vote down vote up
@Override public MustacheVisitor createMustacheVisitor() {
    return new StrictMustacheVisitor(this);
}