private void EmitPage(string fileName, string title, string content) { var destinationFile = GetProjectPath($"docs/{fileName}"); var fileContent = FillTemplate("page", ("NAV", _pageNav), ("TITLE", title), ("CONTENT", content) ); File.WriteAllText(destinationFile, fileContent); }
public void FillTemplateTest() { var f = new FillTemplate(); string template = "{{foo}}"; string[][] placeholders = { new[] { "foo", "bar" } }; Assert.AreEqual("bar", f.fillTemplate(template, placeholders)); template = "Hello, {{foo}}"; placeholders = new[] { new[] { "foo", "bar" } }; Assert.AreEqual("Hello, bar", f.fillTemplate(template, placeholders)); template = "Some {{ text with random {{stuff}} }} in it."; placeholders = new[] { new[] { "stuff", "things" } }; Assert.AreEqual("Some {{ text with random things }} in it.", f.fillTemplate(template, placeholders)); template = "{{nested {{placeholders}} oh noes!}}"; placeholders = new[] { new[] { "nested placeholders! oh noes!", "nah is k" }, new[] { "placeholders", "placeholders!" } }; Assert.AreEqual("nah is k", f.fillTemplate(template, placeholders)); template = "As you might notice, the given {{template}} cannot be loaded properly."; placeholders = new string[][] { }; Assert.AreEqual("As you might notice, the given {{template}} cannot be loaded properly.", f.fillTemplate(template, placeholders)); }