Exemple #1
0
        private void Gather(string filename, Token token)
        {
            foreach(var _token in token.Tokens)
            {
                if (_token is ImportToken)
                {
                    var import = _token as ImportToken;

                    var path = Pathing.Relative(filename, import.Name);

                    if (!this.HaveDocument(path))
                    {
                        var document = LoadDocument(import.Name, path);

                        this.Documents.Add(document);

                        this.Gather(path, document);
                    }
                }

                if(_token is RenderToken)
                {
                    var render = _token as RenderToken;

                    var path = Pathing.Relative(filename, render.Name);

                    if (!this.HaveDocument(path))
                    {
                        var document = LoadDocument(render.Name, path);

                        this.Documents.Add(document);

                        this.Gather(path, document);
                    }
                }

                this.Gather(filename, _token);
            }
        }
Exemple #2
0
        private static void TransformRender(DocumentToken transform, Token token, List<DocumentToken> documents)
        {
            if (token is RenderToken)
            {
                var render = token as RenderToken;

                renderdepth += 1;

                if(renderdepth > 32)
                {
                    renderdepth -= 1;

                    string message = string.Format("error: exceeded maximum render depth for ", render.Name);

                    transform.Tokens.Add(new ContentToken(message, 0, message.Length));

                    return;
                }

                var subdocument = GetDocument(render.Name, documents);

                if (subdocument != null)
                {
                    subdocument = Transform(subdocument, documents);

                    foreach (var _token in subdocument.Tokens)
                    {
                        TransformRender(transform, _token, documents);
                    }
                }

                renderdepth -= 1;

                return;
            }

            if (token is ContentToken)
            {
                transform.Tokens.Add(token);
            }

            foreach (var _token in token.Tokens)
            {
                TransformRender(transform, _token, documents);
            }
        }