示例#1
0
        private static string CompileCollection(string template, dynamic entry)
        {
            var forTag = $"for {entry.Name}";
            var endTag = $"end {entry.Name}";

            var fullForTag = forTag.ParseTag();
            var fullEndTag = endTag.ParseTag();

            var fullChildText = TagHelper.BetweenTagText(template, fullForTag, fullEndTag);
            var childText     = TagHelper.Between(template, fullForTag, fullEndTag);

            var newChildText = string.Empty;

            foreach (var listItem in entry.Value)
            {
                var listText = childText;

                foreach (var childItem in listItem)
                {
                    CompileProperty(childItem, ref listText);
                }

                newChildText += listText;
            }

            return(template.Replace(fullChildText, newChildText));
        }