public ConditionalBlockAccumulatorContext(Expression startingNode) : base(startingNode) { startingNode = UnwrapStatement(startingNode); BlockName = ((HelperExpression)startingNode).HelperName.Replace("#", ""); if (new [] { "if", "unless" }.Contains(BlockName) == false) { throw new HandlebarsCompilerException(string.Format( "Tried to convert {0} expression to conditional block", BlockName)); } var testType = BlockName == "if"; var argument = HandlebarsExpression.Boolish(((HelperExpression)startingNode).Arguments.Single()); _currentCondition = testType ? (Expression)argument : Expression.Not(argument); }
protected override System.Linq.Expressions.Expression VisitBoolishExpression(BoolishExpression bex) { return(HandlebarsExpression.Boolish(Visit(bex.Condition))); }
private Expression GetElseIfTestExpression(Expression item) { item = UnwrapStatement(item); return(HandlebarsExpression.Boolish(((HelperExpression)item).Arguments.Skip(1).Single())); }