Java Code Examples for com.github.mustachejava.util.Wrapper

The following examples show how to use com.github.mustachejava.util.Wrapper. These examples are extracted from open source projects. 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 Project: component-runtime   Source File: TemplateRenderer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Wrapper find(final String name, final List<Object> scopes) {
    final Wrapper wrapper = super.find(name, scopes);
    return s -> {
        final Object call = wrapper.call(s);
        if (Collection.class.isInstance(call) && !DecoratedCollection.class.isInstance(call)) {
            return new DecoratedCollection<>(Collection.class.cast(call));
        }
        return call;
    };
}
 
Example 2
Source Project: dcos-commons   Source File: TemplateUtils.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected synchronized Wrapper getWrapper(String name, List<Object> scopes) {
  Wrapper wrapper = super.getWrapper(name, scopes);
  // This should only do anything when the template param is e.g. "{{hello}}", not "{{#hello}}hi{{/hello}}".
  // The latter case implies an expectation that the value will sometimes be unset. We can determine the
  // situation based on the code type:
  // - "{{hello}}" = ValueCode <-- check for this case
  // - "{{#hello}}{{/hello}}" = IterableCode
  // - "{{^hello}}{{/hello}}" = NotIterableCode
  // - etc... "{{>partial}}", "{{!comment}}"
  if (code instanceof ValueCode && wrapper instanceof MissingWrapper) {
    missingValues.add(new MissingValue(name, tc.line()));
  }
  return wrapper;
}