Exemple #1
0
        LinkedList <Node> RenderTemplateTreeExpand(TemplateNode tnode, ContextStack contextStack)
        {
            LinkedList <Node> nodeList = new LinkedList <Node>();
            bool useFor = tnode.forExpress != null;

            System.Collections.IEnumerable forList = useFor ? tnode.forExpress.Evaluate(contextStack) : new List <object> {
                0
            };
            if (forList != null)
            {
                foreach (object forContext in forList)
                {
                    if (useFor)
                    {
                        contextStack.EnterScope();
                        contextStack.Set(tnode.forExpress.IteratorName, forContext);
                    }
                    bool skipElement = (tnode.ifExpress != null &&
                                        tnode.ifExpress.TryEvaluate(contextStack, out var result) &&
                                        result == false);
                    if (!skipElement)
                    {
                        var fc   = useFor ? forContext : null;
                        var node = RenderTemplateTree(tnode, contextStack, fc);
                        var ra   = GetNodeRuntimeAttribute(node);
                        // ra.IsThunk = useFor;
                        nodeList.AddLast(node);
                    }
                    if (useFor)
                    {
                        contextStack.LeaveScope();
                    }
                }
            }
            return(nodeList);
        }