private string render(String line, TemplateReader reader, String pattern, Dictionary<string, object> parameters, bool renderWithTextBlock = false) { Match lineMatch = Regex.Match(line.Trim(), pattern); String tag = "div"; String text = ""; List<string> attributes = new List<string>(); int level = reader.Level; if (lineMatch.Groups["tag"].Success) { tag = lineMatch.Groups["tag"].Value; } if (lineMatch.Groups["text"].Success) { text = lineMatch.Groups["text"].Value; } StringBuilder textBuilder = new StringBuilder(); if (text.Length > 0) { textBuilder.Append(TemplateRendererUtils.CreateIndent(renderer.LineIndent + 1)); textBuilder.Append(text); textBuilder.Append("\n"); } renderer.LineIndent++; String sourceBlock; if (renderWithTextBlock||textBlockTags.Contains(tag)) { sourceBlock = reader.ReadBlockWithIndent(renderer.LineIndent); sourceBlock = sourceBlock.TrimEnd('\n'); if (sourceBlock.Length > 0) { textBuilder.Append(sourceBlock); textBuilder.Append("\n"); } } else { sourceBlock=reader.ReadBlock(); textBuilder.Append(renderer.RenderBlock(sourceBlock)); } renderer.LineIndent--; if (lineMatch.Groups["id"].Success) { attributes.Add("id=\"" + lineMatch.Groups["id"].Value + "\""); } if (lineMatch.Groups["class"].Success) { attributes.Add("class=\"" + lineMatch.Groups["class"].Value + "\""); } foreach (Capture cap in lineMatch.Groups["attr"].Captures) { attributes.Add(cap.Value.Trim()); } return generateTag(tag, attributes, textBuilder.ToString()); }
public string declareMixin(string line, TemplateReader reader, int patternIndex) { Match m = Regex.Match(line.Trim(), RegularExpressionPatterns[patternIndex]); Mixin mixin = new Mixin(); String mixinName = m.Groups["name"].Value; foreach (Capture cap in m.Groups["attr_name"].Captures) { mixin.parameters.Add(cap.Value); } String block = reader.ReadBlockWithIndent(0); mixin.block = block; mixins.Add(mixinName, mixin); return ""; }