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
Source File: ComponentPresentedHelper.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@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 File: IfNullHelper.java    From cloudbreak with 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 File: EqHelper.java    From cloudbreak with 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 File: NeqHelper.java    From cloudbreak with 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 File: IfHelper.java    From cloudbreak with 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;
}