示例#1
0
        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);
        }
示例#2
0
        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"));
        }
示例#3
0
        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}}"));
        }
示例#4
0
        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}}"));
        }
示例#5
0
 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);
     }
 }
示例#6
0
        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}}"));
        }
示例#7
0
        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}}"));
        }