Iterator() public static method

public static Iterator ( Expression sequence, Expression template ) : HandlebarsDotNet.Compiler.IteratorExpression
sequence System.Linq.Expressions.Expression
template System.Linq.Expressions.Expression
return HandlebarsDotNet.Compiler.IteratorExpression
 public override bool IsClosingElement(Expression item)
 {
     if (IsClosingNode(item))
     {
         // If the template has no content within the block, e.g. `{{#each ...}}{{/each}`, then the block body is a no-op.
         var bodyStatements = _body.Count != 0 ? _body : new List <Expression> {
             Expression.Empty()
         };
         if (_accumulatedExpression == null)
         {
             _accumulatedExpression = HandlebarsExpression.Iterator(
                 _startingNode.Arguments.Single(),
                 Expression.Block(bodyStatements));
         }
         else
         {
             _accumulatedExpression = HandlebarsExpression.Iterator(
                 ((IteratorExpression)_accumulatedExpression).Sequence,
                 ((IteratorExpression)_accumulatedExpression).Template,
                 Expression.Block(bodyStatements));
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
        protected virtual Expression VisitIteratorExpression(IteratorExpression iex)
        {
            Expression sequence = Visit(iex.Sequence);

            // Don't visit Template/IfEmpty - they will be compiled separately

            if (sequence != iex.Sequence)
            {
                return(HandlebarsExpression.Iterator(sequence, iex.BlockParams, iex.Template, iex.IfEmpty));
            }
            return(iex);
        }
 public override void HandleElement(Expression item)
 {
     if (IsElseBlock(item))
     {
         _accumulatedExpression = HandlebarsExpression.Iterator(
             _startingNode.Arguments.Single(),
             Expression.Block(_body));
         _body = new List <Expression>();
     }
     else
     {
         _body.Add((Expression)item);
     }
 }
Beispiel #4
0
 public override void HandleElement(Expression item)
 {
     if (IsElseBlock(item))
     {
         _accumulatedExpression = HandlebarsExpression.Iterator(
             _startingNode.Arguments.Single(o => o.NodeType != (ExpressionType)HandlebarsExpressionType.BlockParamsExpression),
             _startingNode.Arguments.OfType <BlockParamsExpression>().SingleOrDefault() ?? BlockParamsExpression.Empty(),
             Expression.Block(_body));
         _body = new List <Expression>();
     }
     else
     {
         _body.Add((Expression)item);
     }
 }
 public override bool IsClosingElement(Expression item)
 {
     if (IsClosingNode(item))
     {
         if (_accumulatedExpression == null)
         {
             _accumulatedExpression = HandlebarsExpression.Iterator(
                 _startingNode.Arguments.Single(),
                 Expression.Block(_body));
         }
         else
         {
             _accumulatedExpression = HandlebarsExpression.Iterator(
                 ((IteratorExpression)_accumulatedExpression).Sequence,
                 ((IteratorExpression)_accumulatedExpression).Template,
                 Expression.Block(_body));
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }