コード例 #1
0
        public void Visit(CustomTag customTag)
        {
            //Console.WriteLine("Looking up Custom Tag " + customTag.TagName);
            var tagType = _templateContext.SymbolTableStack.LookupCustomTagRendererType(customTag.TagName);
            if (tagType != null)
            {
                AppendTextToCurrentAccumulator(RenderCustomTag(customTag, tagType));
                return;
            }

            //Console.WriteLine("Looking up Macro "+ customTag.TagName);
            var macroDescription = _templateContext.SymbolTableStack.LookupMacro(customTag.TagName);
            if (macroDescription != null)
            {
                //Console.WriteLine("...");
                //var evalResult = LiquidExpressionEvaluator.Eval(customTag.LiquidExpressionTrees, _templateContext.SymbolTableStack);
                var evalResults =
                    customTag.LiquidExpressionTrees.Select(x => LiquidExpressionEvaluator.Eval(x, _templateContext)).ToList();
                if (evalResults.Any(x => x.IsError))
                {
                    RenderErrors(evalResults);
                    return;
                }
                AppendTextToCurrentAccumulator(RenderMacro(macroDescription, evalResults.Select(x => x.SuccessResult)));
                return;
            }
            //_result += " ERROR: There is no macro or tag named "+  customTag.TagName+ " ";
            AddError("Liquid syntax error: Unknown tag '" + customTag.TagName + "'", customTag);
            //_result += "Liquid syntax error: Unknown tag '"+customTag.TagName+"'";
        }
コード例 #2
0
 public static CustomBlockTag CreateFromCustomTag(CustomTag tag, TreeNode<IASTNode> liquidBlock)
 {
    return new CustomBlockTag(tag.TagName)
     {
         LiquidExpressionTrees = tag.LiquidExpressionTrees,
         LiquidBlock = liquidBlock
     };
 }
コード例 #3
0
 public static CustomBlockTag CreateFromCustomTag(CustomTag tag, TreeNode <IASTNode> liquidBlock)
 {
     return(new CustomBlockTag(tag.TagName)
     {
         LiquidExpressionTrees = tag.LiquidExpressionTrees,
         LiquidBlock = liquidBlock
     });
 }
コード例 #4
0
 public void Visit(CustomTag customTag)
 {
     _result += customTag.ToString();
 }
コード例 #5
0
        private String RenderCustomTag(CustomTag customTag, Type tagType)
        {
            var tagRenderer = CustomTagRendererFactory.Create(tagType);
            String result = "";
            EvalExpressions(customTag.LiquidExpressionTrees,
                args => result = tagRenderer.Render(_templateContext, args.ToList()).StringVal,
                errors => result = FormatErrors(errors));
            return result;

       }