com.github.mustachejava.DefaultMustacheVisitor Java Examples

The following examples show how to use com.github.mustachejava.DefaultMustacheVisitor. 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);
                    }
                }
            });
        }
    };
}