public ConditionalBlockAccumulatorContext(Expression startingNode) { var item = (HelperExpression)UnwrapStatement(startingNode); BlockName = item.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.BoolishExpression(item.Arguments.Single()); _currentCondition = testType ? (Expression)argument : Expression.Not(argument); }
private static Expression GetElseIfTestExpression(Expression item) { item = UnwrapStatement(item); return(HandlebarsExpression.BoolishExpression(((HelperExpression)item).Arguments.Skip(1).Single())); }
protected override Expression VisitBoolishExpression(BoolishExpression bex) { return(HandlebarsExpression.BoolishExpression(Visit(bex.ConditionExpression))); }