public void ShouldRemoveContentsWhenFalse() { var document = TestDocument.Create("{{#if False}}Hello World{{/if}}"); var replacedDocument = HandlebarsDocument.Replace(document, this); var innerText = replacedDocument.MainDocumentPart.Document.Body.InnerText; Assert.Equal("", innerText); }
public void ShouldReplaceNestedProperty() { var document = TestDocument.Create("{{Person.FirstName}}"); var replacedDocument = HandlebarsDocument.Replace(document, this); var innerText = replacedDocument.MainDocumentPart.Document.Body.InnerText; Assert.True(innerText.Contains("Andrew")); }
public void ShouldReplaceTokensSpreadoverTextNodes() { var document = TestDocument.Create(new Text("{"), new Text("{"), new Text("Hello"), new Text("}"), new Text("}")); var replacedDocument = HandlebarsDocument.Replace(document, this); var innerText = replacedDocument.MainDocumentPart.Document.Body.InnerText; Assert.True(innerText.Contains("Hello World")); Assert.False(innerText.Contains("{{Hello}}")); }
public void ShouldReplaceBasicHandlebarsSyntax() { var document = TestDocument.Create("{{Hello}}"); var replacedDocument = HandlebarsDocument.Replace(document, this); var innerText = replacedDocument.MainDocumentPart.Document.Body.InnerText; Assert.True(innerText.Contains("Hello World")); Assert.False(innerText.Contains("{{Hello}}")); }
public void ReplacePropertyOnNestedObject() { using (var docs = TestDocument.Create("{{#with Person}}{{FirstName}}{{/with}}")) { var replacedDocument = HandlebarsDocument.Replace(docs, this); var innerText = replacedDocument.MainDocumentPart.Document.Body.InnerText; Assert.Equal("Andrew", docs.MainDocumentPart.Document.Body.InnerText); } }
public void ShouldShowContentsWhenTrue() { var document = TestDocument.Create("{{#if True}}Hello World{{/if}}"); var replacedDocument = HandlebarsDocument.Replace(document, this); var innerText = replacedDocument.MainDocumentPart.Document.Body.InnerText; Assert.True(innerText.Contains("Hello World")); Assert.False(innerText.Contains("{{#if Visibile}}")); }
public void ShouldReplaceMultipleTokens() { var document = TestDocument.Create("{{Hello}}, {{Name}}"); var replacedDocument = HandlebarsDocument.Replace(document, this); var innerText = replacedDocument.MainDocumentPart.Document.Body.InnerText; Assert.True(innerText.Contains("Hello World, Andy")); Assert.False(innerText.Contains("{{Hello}}")); Assert.False(innerText.Contains("{{Name}}")); }