@Override public void execute (Template tmpl, Template.Context ctx, Writer out) { Object value = tmpl.getSectionValue(ctx, _name, _line); // won't return null Iterator<?> iter = _comp.collector.toIterator(value); if (iter != null) { int index = 0; while (iter.hasNext()) { Object elem = iter.next(); boolean onFirst = (index == 0), onLast = !iter.hasNext(); executeSegs(tmpl, ctx.nest(elem, ++index, onFirst, onLast), out); } } else if (value instanceof Boolean) { if ((Boolean)value) { executeSegs(tmpl, ctx, out); } } else if (value instanceof Lambda) { try { ((Lambda)value).execute(tmpl.createFragment(_segs, ctx), out); } catch (IOException ioe) { throw new MustacheException(ioe); } } else if (_comp.isFalsey(value)) { // omit the section } else { executeSegs(tmpl, ctx.nest(value), out); } } @Override public void decompile (Delims delims, StringBuilder into) {
@Override public void execute (Template tmpl, Template.Context ctx, Writer out) { Object value = tmpl.getSectionValue(ctx, _name, _line); // won't return null Iterator<?> iter = _comp.collector.toIterator(value); if (iter != null) { if (!iter.hasNext()) { executeSegs(tmpl, ctx, out); } } else if (value instanceof Boolean) { if (!(Boolean)value) { executeSegs(tmpl, ctx, out); } } else if (value instanceof InvertibleLambda) { try { ((InvertibleLambda)value).executeInverse(tmpl.createFragment(_segs, ctx), out); } catch (IOException ioe) { throw new MustacheException(ioe); } } else if (_comp.isFalsey(value)) { executeSegs(tmpl, ctx, out); } // TODO: fail? } @Override public void decompile (Delims delims, StringBuilder into) {
@Override public void execute (Template tmpl, Template.Context ctx, Writer out) { Object value = tmpl.getSectionValue(ctx, _name, _line); // won't return null Iterator<?> iter = _comp.collector.toIterator(value); if (iter != null) { int index = 0; while (iter.hasNext()) { Object elem = iter.next(); boolean onFirst = (index == 0), onLast = !iter.hasNext(); executeSegs(tmpl, ctx.nest(elem, ++index, onFirst, onLast), out); } } else if (value instanceof Boolean) { if ((Boolean)value) { executeSegs(tmpl, ctx, out); } } else if (value instanceof Lambda) { try { ((Lambda)value).execute(tmpl.createFragment(_segs, ctx), out); } catch (IOException ioe) { throw new MustacheException(ioe); } } else if (_comp.isFalsey(value)) { // omit the section } else { executeSegs(tmpl, ctx.nest(value), out); } } @Override public void decompile (Delims delims, StringBuilder into) {
@Override public void execute (Template tmpl, Template.Context ctx, Writer out) { Object value = tmpl.getSectionValue(ctx, _name, _line); // won't return null Iterator<?> iter = _comp.collector.toIterator(value); if (iter != null) { if (!iter.hasNext()) { executeSegs(tmpl, ctx, out); } } else if (value instanceof Boolean) { if (!(Boolean)value) { executeSegs(tmpl, ctx, out); } } else if (value instanceof InvertibleLambda) { try { ((InvertibleLambda)value).executeInverse(tmpl.createFragment(_segs, ctx), out); } catch (IOException ioe) { throw new MustacheException(ioe); } } else if (_comp.isFalsey(value)) { executeSegs(tmpl, ctx, out); } // TODO: fail? } @Override public void decompile (Delims delims, StringBuilder into) {