BlockHelper() public static method

public static BlockHelper ( string helperName, IEnumerable arguments, Expression body, Expression inversion ) : HandlebarsDotNet.Compiler.BlockHelperExpression
helperName string
arguments IEnumerable
body System.Linq.Expressions.Expression
inversion System.Linq.Expressions.Expression
return HandlebarsDotNet.Compiler.BlockHelperExpression
Beispiel #1
0
        public override Expression GetAccumulatedBlock()
        {
            if (_accumulatedBody == null)
            {
                _accumulatedBody      = GetBlockBody();
                _accumulatedInversion = Expression.Block(Expression.Empty());
            }
            else if (_accumulatedInversion == null)
            {
                _accumulatedInversion = GetBlockBody();
            }

            var resultExpr = HandlebarsExpression.BlockHelper(
                _startingNode.HelperName,
                _startingNode.Arguments.Where(o => o.NodeType != (ExpressionType)HandlebarsExpressionType.BlockParamsExpression),
                _startingNode.Arguments.OfType <BlockParamsExpression>().SingleOrDefault() ?? BlockParamsExpression.Empty(),
                _accumulatedBody,
                _accumulatedInversion,
                _startingNode.IsRaw);

            if (_startingNode.IsRaw)
            {
                return(HandlebarsExpression.Statement(
                           resultExpr,
                           false,
                           _trimBefore,
                           _trimAfter));
            }

            return(resultExpr);
        }
Beispiel #2
0
        public override Expression GetAccumulatedBlock()
        {
            if (_accumulatedBody == null)
            {
                _accumulatedBody      = GetBlockBody();
                _accumulatedInversion = Expression.Block(Expression.Empty());
            }
            else if (_accumulatedInversion == null)
            {
                _accumulatedInversion = GetBlockBody();
            }

            var resultExpr = HandlebarsExpression.BlockHelper(
                _startingNode.HelperName,
                _startingNode.Arguments,
                _accumulatedBody,
                _accumulatedInversion,
                _startingNode.IsRaw);

            if (_startingNode.IsRaw)
            {
                return(HandlebarsExpression.Statement(
                           resultExpr,
                           false,
                           _trimBefore,
                           _trimAfter));
            }

            return(resultExpr);
        }
 protected override Expression VisitBlockHelperExpression(BlockHelperExpression bhex)
 {
     return(HandlebarsExpression.BlockHelper(
                bhex.HelperName,
                bhex.Arguments.Select(arg => Visit(arg)),
                Visit(bhex.Body),
                Visit(bhex.Inversion)));
 }
        protected virtual Expression VisitBlockHelperExpression(BlockHelperExpression bhex)
        {
            var arguments = VisitExpressionList(bhex.Arguments);

            // Don't visit Body/Inversion - they will be compiled separately

            if (arguments != bhex.Arguments)
            {
                return(HandlebarsExpression.BlockHelper(bhex.HelperName, arguments, bhex.BlockParams, bhex.Body, bhex.Inversion, bhex.IsRaw));
            }
            return(bhex);
        }
Beispiel #5
0
        public override Expression GetAccumulatedBlock()
        {
            if (_accumulatedBody == null)
            {
                _accumulatedBody      = GetBlockBody();
                _accumulatedInversion = Expression.Block(Expression.Empty());
            }
            else if (_accumulatedInversion == null)
            {
                _accumulatedInversion = GetBlockBody();
            }

            return(HandlebarsExpression.BlockHelper(
                       _startingNode.HelperName,
                       _startingNode.Arguments,
                       _accumulatedBody,
                       _accumulatedInversion));
        }