protected static async Task <string> ParseElementAsync(IParseManager parseManager, ListInfo listInfo, List <KeyValuePair <int, Dictionary <string, object> > > dataSource) { var pageInfo = parseManager.PageInfo; if (dataSource == null || dataSource.Count == 0) { return(string.Empty); } var builder = new StringBuilder(); if (listInfo.Layout == Layout.None) { if (!string.IsNullOrEmpty(listInfo.HeaderTemplate)) { builder.Append(listInfo.HeaderTemplate); } var isAlternative = false; var isSeparator = false; if (!string.IsNullOrEmpty(listInfo.AlternatingItemTemplate)) { isAlternative = true; } if (!string.IsNullOrEmpty(listInfo.SeparatorTemplate)) { isSeparator = true; } for (var i = 0; i < dataSource.Count; i++) { var dict = dataSource[i]; pageInfo.SqlItems.Push(dict); var templateString = isAlternative && i % 2 == 1 ? listInfo.AlternatingItemTemplate : listInfo.ItemTemplate; builder.Append(await TemplateUtility.GetSqlContentsTemplateStringAsync(templateString, listInfo.SelectedItems, listInfo.SelectedValues, string.Empty, parseManager, ParseType.SqlContent)); if (isSeparator && i != dataSource.Count - 1) { builder.Append(listInfo.SeparatorTemplate); } } if (!string.IsNullOrEmpty(listInfo.FooterTemplate)) { builder.Append(listInfo.FooterTemplate); } } else { var isAlternative = !string.IsNullOrEmpty(listInfo.AlternatingItemTemplate); var tableAttributes = listInfo.GetTableAttributes(); var cellAttributes = listInfo.GetCellAttributes(); using (var table = new HtmlTable(builder, tableAttributes)) { if (!string.IsNullOrEmpty(listInfo.HeaderTemplate)) { table.StartHead(); using (var tHead = table.AddRow()) { tHead.AddCell(listInfo.HeaderTemplate, cellAttributes); } table.EndHead(); } table.StartBody(); var columns = listInfo.Columns <= 1 ? 1 : listInfo.Columns; var itemIndex = 0; while (true) { using var tr = table.AddRow(); for (var cell = 1; cell <= columns; cell++) { var cellHtml = string.Empty; if (itemIndex < dataSource.Count) { var dict = dataSource[itemIndex]; pageInfo.SqlItems.Push(dict); var templateString = isAlternative && itemIndex % 2 == 1 ? listInfo.AlternatingItemTemplate : listInfo.ItemTemplate; cellHtml = await TemplateUtility.GetSqlContentsTemplateStringAsync(templateString, listInfo.SelectedItems, listInfo.SelectedValues, string.Empty, parseManager, ParseType.SqlContent); } tr.AddCell(cellHtml, cellAttributes); itemIndex++; } if (itemIndex >= dataSource.Count) { break; } } table.EndBody(); if (!string.IsNullOrEmpty(listInfo.FooterTemplate)) { table.StartFoot(); using (var tFoot = table.AddRow()) { tFoot.AddCell(listInfo.FooterTemplate, cellAttributes); } table.EndFoot(); } } } return(builder.ToString()); }