public void Visit(IfThenElseBlockTag ifThenElseBlockTag) { _result += ifThenElseBlockTag.ToString(); _result += ifThenElseBlockTag.IfElseClauses.Select(x => VisitIfTag(x.LiquidExpressionTree)); }
public void Visit(IfThenElseBlockTag ifThenElseBlockTag) { // find the first place where the expression tree evaluates to true (i.e. which of the if/elsif/else clauses) // This ignores "eval" errors in clauses. var match = ifThenElseBlockTag.IfElseClauses.FirstOrDefault( expr => { var result = LiquidExpressionEvaluator.Eval(expr.LiquidExpressionTree, _templateContext); return result.IsSuccess && result.SuccessResult.HasValue && result.SuccessResult.Value.IsTrue; }); if (match != null) { StartWalking(match.LiquidBlock); // then render the contents } }