private void Test1(string prefix, string open, string close, string content, string expectedTagName, string expectedTagContent, IDictionary <string, string> args, int expectedTagPosition = 0, string expectedContent = "") { var doc = new DomDocParser(prefix, open, close); var result = doc.Parse(content); var first = result.Tags[0]; Assert.AreEqual(result.Content, expectedContent); Assert.AreEqual(result.Tags.Count, 1); Assert.AreEqual(first.Position, expectedTagPosition); Assert.AreEqual(first.Name, expectedTagName); Assert.AreEqual(first.InnerContent, expectedTagContent); foreach (var pair in args) { Assert.IsTrue(first.Attributes.Contains(pair.Key)); Assert.AreEqual(first.Attributes[pair.Key], pair.Value); } }
/// <summary> /// Builds the content by replacing any custom cms tags with their actual content. /// </summary> /// <param name="content"></param> /// <param name="components"></param> /// <returns></returns> public string BuildContent(string content) { var doc = new DomDocParser(_prefix, _openBracket, _closeBracket); var result = doc.Parse(content); if (result == null || result.Tags == null || result.Tags.Count == 0) { return(content); } var buffer = new StringBuilder(); foreach (var tag in result.Tags) { var macro = Create(tag.Name); buffer.Append(macro.Process(tag)); } string finalText = buffer.ToString(); return(finalText); }
private void Test1(string prefix, string open, string close, string content, string expectedTagName, string expectedTagContent, IDictionary<string, string> args, int expectedTagPosition = 0, string expectedContent = "") { var doc = new DomDocParser(prefix, open, close); var result = doc.Parse(content); var first = result.Tags[0]; Assert.AreEqual(result.Content, expectedContent); Assert.AreEqual(result.Tags.Count, 1); Assert.AreEqual(first.Position, expectedTagPosition); Assert.AreEqual(first.Name, expectedTagName); Assert.AreEqual(first.InnerContent, expectedTagContent); foreach (var pair in args) { Assert.IsTrue(first.Attributes.Contains(pair.Key)); Assert.AreEqual(first.Attributes[pair.Key], pair.Value); } }