コード例 #1
0
        public void Visit(CaseWhenElseBlockTag caseWhenElseBlockTag)
        {
            var valueToMatchResult = LiquidExpressionEvaluator.Eval(caseWhenElseBlockTag.LiquidExpressionTree, _templateContext);

            //Console.WriteLine("Value to Match: "+valueToMatch);
            if (valueToMatchResult.IsError)
            {
                RegisterRenderingError(valueToMatchResult.ErrorResult);
                //RenderError(valueToMatchResult.ErrorResult);
                return;
            }

            var match =
                caseWhenElseBlockTag.WhenClauses.FirstOrDefault(
                    expr =>
                    // Take the valueToMatch "Case" expression result value
                    // and check if it's equal to the expr.GroupNameExpressionTree expression.
                    // THe "EasyValueComparer" is supposed to match stuff fairly liberally,
                    // though it doesn't cast values---probably it should.

                    expr.LiquidExpressionTree.Any(val =>
                                                  new EasyOptionComparer().Equals(valueToMatchResult.SuccessResult,
                                                                                  LiquidExpressionEvaluator.Eval(val, _templateContext).SuccessResult)));


            if (match != null)                   // found match
            {
                StartWalking(match.LiquidBlock); // so eval + render the HTML
            }
            else if (caseWhenElseBlockTag.HasElseClause)
            {
                StartWalking(caseWhenElseBlockTag.ElseClause.LiquidBlock);
            }
        }
コード例 #2
0
 public void Visit(CaseWhenElseBlockTag caseWhenElseBlockTag)
 {
     _result += caseWhenElseBlockTag.ToString();
 }