Пример #1
0
 private void ProcessTemplate(FluidTemplate template, ExtractingLiquidWalker visitor, string path)
 {
     foreach (var statement in template.Statements)
     {
         visitor.Visit(new LiquidStatementContext()
         {
             Statement = statement, FilePath = path
         });
     }
 }
Пример #2
0
        public void Process(string path, string basePath, LocalizableStringCollection strings)
        {
            var liquidMetadataProvider = new LiquidMetadataProvider(basePath);
            var liquidVisitor          = new ExtractingLiquidWalker(new[] { new LiquidStringExtractor(liquidMetadataProvider) }, strings);

            foreach (var file in Directory.EnumerateFiles(path, "*.liquid", SearchOption.AllDirectories).OrderBy(file => file))
            {
                using (var stream = File.OpenRead(file)) {
                    using (var reader = new StreamReader(stream)) {
                        if (_parser.TryParse(reader.ReadToEnd(), true, out var ast, out var errors))
                        {
                            foreach (var statement in ast)
                            {
                                liquidVisitor.Visit(new LiquidStatementContext()
                                {
                                    Statement = statement, FilePath = file
                                });
                            }
                        }
                    }
                }
            }
        }