Пример #1
0
 private void GenerateCodeFromBlock(Template template, Block block, Dictionary <string, object> data, StringBuilder sb)
 {
     foreach (ParseNode node in block.childNodes)
     {
         if (node is TextNode)
         {
             TextNode tn = node as TextNode;
             GenerateCodeFromTextNode(tn, data, sb);
         }
         else if (node is ForeachWithBlock)
         {
             ForeachWithBlock fewb = node as ForeachWithBlock;
             GenerateCodeFromForeachWithBlock(template, fewb, data[fewb.dataKey] as List <Dictionary <string, object> >, fewb.blockRef.Find(template), sb);
         }
         else if (node is InsertBlock)
         {
             InsertBlock ib = node as InsertBlock;
             GenerateCodeFromBlock(template, ib.blockRef.Find(template), data, sb);
         }
         else if (node is If)
         {
             If @if = node as If;
             GenerateCodeFromIfStatement(template, @if, data, sb);
         }
     }
 }
        private InsertBlock ReadInsertBlock()
        {
            InsertBlock result = new InsertBlock();

            result.lineNr = GetLineNr();

            string line  = ReadLine();
            Match  match = PATTERN_INSERT_BLOCK.Match(line);

            result.blockRef = new BlockRef {
                blockName = match.Groups[GROUP_INSERT_BLOCK_BLOCKREF].Value, lineNr = GetLineNr()
            };
            result.leadingSpaces = match.Groups[GROUP_INSERT_BLOCK_LEADING].Value;

            return(result);
        }