com.github.mustachejava.util.Wrapper Java Examples
The following examples show how to use
com.github.mustachejava.util.Wrapper.
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: TemplateRenderer.java From component-runtime with Apache License 2.0 | 5 votes |
@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 File: TemplateUtils.java From dcos-commons with Apache License 2.0 | 5 votes |
@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; }