示例#1
0
        internal static ASTNode GetTemplateNode(JinjaEnvironment environment, string templateText)
        {
            var     lexer          = new Lexer(environment);
            var     tokens         = lexer.Tokenize(templateText).ToArray();
            var     parsed         = Parser.Parse(tokens).ToArray();
            var     outputCombined = OutputCombiner.CombineOutput(parsed);
            ASTNode templateNode   = ASTGenerator.ParseTemplate(environment, lexer, outputCombined);

            //templateNode = templateNode.Transform(CommentRemoverTransformer.Instance);
            templateNode = WhiteSpaceController.ControlWhiteSpace(environment, templateNode);

            return(templateNode);
        }
示例#2
0
        internal static string CheckOriginalText(JinjaEnvironment environment, string templateText)
        {
            var     lexer          = new Lexer(environment);
            var     tokens         = lexer.Tokenize(templateText).ToArray();
            var     parsed         = Parser.Parse(tokens).ToArray();
            var     outputCombined = OutputCombiner.CombineOutput(parsed);
            ASTNode templateNode   = ASTGenerator.ParseTemplate(environment, lexer, outputCombined);

            var stringBuilder = new StringBuilder();

            templateNode.ToOriginalText(stringBuilder);
            return(stringBuilder.ToString());
        }