public void TestItemCountFunction() { string srcText = "12345"; string templateScript = @"@{ (for i (itemCount) 0 ($i) ) @}"; RTMatcher matcher = new RTMatcher(@"(\d)+", new MatchOptions() { MatchType = MatchType.Capture }); var match = matcher.Execute(srcText); RTTemplate template = new RTTemplate(templateScript, new TemplateOptions()); string result = template.Execute(match[0]); Assert.AreEqual(result, "54321"); }
public void TestGetFunction() { string srcText = "1 2 3 4 5"; string templateScript = @"@{ (for i 1 5 (+ ($i) 1) ) @}"; RTMatcher matcher = new RTMatcher(@"(\d)\s(\d)\s(\d)\s(\d)\s(\d)", new MatchOptions()); var match = matcher.Execute(srcText); RTTemplate template = new RTTemplate(templateScript, new TemplateOptions()); string result = template.Execute(match[0]); Assert.AreEqual(result, "23456"); }