Exemplo n.º 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
         });
     }
 }
Exemplo n.º 2
0
 private void ProcessTemplate(IFluidTemplate template, ExtractingLiquidWalker visitor, string path)
 {
     if (template is CompositeFluidTemplate compositeTemplate)
     {
         foreach (var innerTemplate in compositeTemplate.Templates)
         {
             ProcessTemplate(innerTemplate, visitor, path);
         }
     }
     else if (template is FluidTemplate singleTemplate)
     {
         ProcessTemplate(singleTemplate, visitor, path);
     }
 }
Exemplo n.º 3
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(), out var template, out var errors))
                        {
                            ProcessTemplate(template, liquidVisitor, file);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
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))
            {
                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
                                });
                            }
                        }
                    }
                }
            }
        }