private Expression AccumulateBlock( IEnumerator<object> enumerator, BlockAccumulatorContext context) { while(enumerator.MoveNext()) { var item = (Expression)enumerator.Current; var innerContext = BlockAccumulatorContext.Create(item, _configuration); if(innerContext != null) { context.HandleElement(AccumulateBlock(enumerator, innerContext)); } else if(context.IsClosingElement(item)) { return context.GetAccumulatedBlock(); } else { context.HandleElement(item); } } throw new HandlebarsCompilerException("Reached end of template before block expression was closed"); }