private void GenerateCodeFromForeachWithBlock(Template template, ForeachWithBlock fewb, List <Dictionary <string, object> > dataList, Block block, StringBuilder sb) { foreach (Dictionary <string, object> data in dataList) { GenerateCodeFromBlock(template, block, data, sb); } }
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 ForeachWithBlock ReadForeachWithBlock() { ForeachWithBlock result = new ForeachWithBlock(); result.lineNr = GetLineNr(); string line = ReadLine(); Match match = PATTERN_FOREACH_WITH_BLOCK.Match(line); result.blockRef = new BlockRef { blockName = match.Groups[GROUP_FOREACH_WITH_BLOCK_BLOCKREF].Value, lineNr = GetLineNr() }; result.dataKey = match.Groups[GROUP_FOREACH_WITH_BLOCK_KEY].Value; return(result); }