protected override Expression VisitHelperExpression(HelperExpression hex)
 {
     if (_context.Configuration.Helpers.ContainsKey(hex.HelperName))
     {
         var helper = _context.Configuration.Helpers[hex.HelperName];
         var arguments = new Expression[] {
             Expression.Property(
                 _context.BindingContext,
                 typeof(BindingContext).GetProperty("TextWriter")),
             Expression.Property(
                 _context.BindingContext,
                 typeof(BindingContext).GetProperty("Value")),
             Expression.NewArrayInit(typeof(object), hex.Arguments)
         };
         if(helper.Target != null)
         {
             return Expression.Call(
                 Expression.Constant(helper.Target),
                 helper.Method,
                 arguments);
         }
         else
         {
             return Expression.Call(
                 helper.Method,
                 arguments);
         }
     }
     else
     {
         return hex;
     }
 }
 protected override Expression VisitHelperExpression(HelperExpression hex)
 {
     if (_context.Configuration.Helpers.ContainsKey(hex.HelperName))
     {
         var helper    = _context.Configuration.Helpers[hex.HelperName];
         var arguments = new Expression[] {
             Expression.Property(
                 _context.BindingContext,
                 typeof(BindingContext).GetProperty("TextWriter")),
             Expression.Property(
                 _context.BindingContext,
                 typeof(BindingContext).GetProperty("Value")),
             Expression.NewArrayInit(typeof(object), hex.Arguments)
         };
         if (helper.Target != null)
         {
             return(Expression.Call(
                        Expression.Constant(helper.Target),
                        helper.Method,
                        arguments));
         }
         else
         {
             return(Expression.Call(
                        helper.Method,
                        arguments));
         }
     }
     else
     {
         return(hex);
     }
 }
 private static Expression CreateIfBlock(HelperExpression startingNode, IEnumerable<Expression> body)
 {
     var condition = HandlebarsExpression.Boolish(startingNode.Arguments.Single());
     if(startingNode.HelperName == "#if")
     {
         return Expression.IfThen(condition, Expression.Block(body));
     }
     else if(startingNode.HelperName == "#unless")
     {
         return Expression.IfThen(Expression.Not(condition), Expression.Block(body));
     }
     else
     {
         throw new HandlebarsCompilerException(string.Format(
             "Tried to create a conditional expression for '{0}'", startingNode.HelperName));
     }
 }
        private static Expression CreateIfBlock(HelperExpression startingNode, IEnumerable <Expression> body)
        {
            var condition = HandlebarsExpression.Boolish(startingNode.Arguments.Single());

            if (startingNode.HelperName == "#if")
            {
                return(Expression.IfThen(condition, Expression.Block(body)));
            }
            else if (startingNode.HelperName == "#unless")
            {
                return(Expression.IfThen(Expression.Not(condition), Expression.Block(body)));
            }
            else
            {
                throw new HandlebarsCompilerException(string.Format(
                                                          "Tried to create a conditional expression for '{0}'", startingNode.HelperName));
            }
        }
 public BlockHelperAccumulatorContext(Expression startingNode)
     : base(startingNode)
 {
     startingNode  = UnwrapStatement(startingNode);
     _startingNode = (HelperExpression)startingNode;
 }
Пример #6
0
 protected override Expression VisitHelperExpression(HelperExpression hex)
 {
     return(HandlebarsExpression.Helper(
                hex.HelperName,
                hex.Arguments.Select(arg => Visit(arg))));
 }
 public BlockHelperAccumulatorContext(Expression startingNode)
     : base(startingNode)
 {
     startingNode = UnwrapStatement(startingNode);
     _startingNode = (HelperExpression)startingNode;
 }
 protected virtual Expression VisitHelperExpression(HelperExpression hex)
 {
     return hex;
 }
Пример #9
0
 protected virtual Expression VisitHelperExpression(HelperExpression hex)
 {
     return(hex);
 }
Пример #10
0
 protected override Expression VisitHelperExpression(HelperExpression hex)
 {
     return HandlebarsExpression.Helper(
         hex.HelperName,
         hex.Arguments.Select(arg => Visit(arg)));
 }