Java Code Examples for com.github.jknack.handlebars.Options#buffer()

The following examples show how to use com.github.jknack.handlebars.Options#buffer() . 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
@Override
public Object apply(Set<String> context, Options options)
        throws IOException {
    String first = options.param(0, null);

    Validate.notNull(first, "found 'null', expected 'first'");
    if (context == null) {
        context = new HashSet<>();
    }

    Buffer buffer = options.buffer();
    if (!context.contains(first)) {
        buffer.append(options.inverse());
    } else {
        buffer.append(options.fn());
    }
    return buffer;
}
 
Example 2
Source Project: cloudbreak   File: IfNullHelper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object apply(Object context, Options options) throws IOException {
    Buffer buffer = options.buffer();

    if (context == null) {
        buffer.append(options.fn());
    } else {
        buffer.append(options.inverse());
    }
    return buffer;
}
 
Example 3
Source Project: cloudbreak   File: EqHelper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object apply(Object context, Options options)
        throws IOException {
    String first = options.param(0, null);

    Validate.notNull(first, "found 'null', expected 'first'");

    Buffer buffer = options.buffer();
    if (!first.equals(context.toString())) {
        buffer.append(options.inverse());
    } else {
        buffer.append(options.fn());
    }
    return buffer;
}
 
Example 4
Source Project: cloudbreak   File: NeqHelper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object apply(Object context, Options options)
        throws IOException {
    String first = options.param(0, null);

    Validate.notNull(first, "found 'null', expected 'first'");

    Buffer buffer = options.buffer();
    if (first.equals(context)) {
        buffer.append(options.inverse());
    } else {
        buffer.append(options.fn());
    }
    return buffer;
}
 
Example 5
Source Project: cloudbreak   File: IfHelper.java    License: Apache License 2.0 5 votes vote down vote up
protected Object decision(Boolean context, Options options) throws IOException {
    if (context == null) {
        context = false;
    }

    Buffer buffer = options.buffer();
    if (context) {
        buffer.append(options.inverse());
    } else {
        buffer.append(options.fn());
    }
    return buffer;
}