Пример #1
0
        public void Test_template_registration_with_partial_include()
        {
            var collection = new TemplateCollection();

            collection.AddTemplate("test", "Hi {{User.Name}}, {{> include/partial}}");
            collection.AddTemplate("include/partial", "Included for {{User.Name}}");

            var template = collection.GetTemplate("test");
            var data     = new Dictionary <string, object>()
            {
                { "User", new { Name = "Test123" } }
            };

            using (var writer = new StringWriter())
            {
                template.Render(data, writer);

                writer.ToString().Should().Be("Hi Test123, Included for Test123");
            }
        }
Пример #2
0
        public void Test_template_registration()
        {
            var collection = new TemplateCollection();

            collection.AddTemplate("test", "Hi {{User.Name}}");

            var template = collection.GetTemplate("test");

            template.Should().NotBeNull();
            template.Name.Should().Be("test");
            template.RenderIntoString(new
            {
                User = new
                {
                    Name = "Test123"
                }
            }).Should().Be("Hi Test123");
        }
Пример #3
0
        public void Test_template_registration()
        {
            var collection = new TemplateCollection();

            collection.AddTemplate("test", "Hi {{User.Name}}");

            var template = collection.GetTemplate("test");

            template.Should().NotBeNull();

            var data = new Dictionary <string, object>()
            {
                { "User", new { Name = "Test123" } }
            };

            using (var writer = new StringWriter())
            {
                template.Render(data, writer);

                writer.ToString().Should().Be("Hi Test123");
            }
        }