public void DynamicObjectBasicTest()
        {
            var model = new MyDynamicModel();

            var source = "Foo: {{foo}}\nBar: {{bar}}";

            var template = Handlebars.Compile(source);

            var output = template(model);

            Assert.AreEqual("Foo: 1\nBar: hello world", output);
        }
Esempio n. 2
0
        public void DynamicObjectBasicTest()
        {
            var model = new MyDynamicModel();

            var source = "Foo: {{foo}}\nBar: {{bar}}";

            var template = Handlebars.Compile(source);

            var output = template(model);

            Assert.Equal("Foo: 1\nBar: hello world", output);
        }
Esempio n. 3
0
        public void DynamicObjectBasicIterationTest()
        {
            var model = new MyDynamicModel();

            var source = "{{#each this}}{{@key}}: {{@value}}\n{{/each}}";

            var template = Handlebars.Compile(source);

            var output = template(model);

            Assert.Equal("foo: 1\nbar: hello world\n", output);
        }
Esempio n. 4
0
        public void CanUseDynamicModelInLayout()
        {
            var files = new FakeFileSystem
            {
                { "views\\layout.hbs", "Layout: {{property}}\r\n{{{body}}}" },
                { "views\\someview.hbs", "{{!< layout}}\r\n\r\nBody: {{property}}" },
            };

            dynamic model = new MyDynamicModel();
            var     handlebarsConfiguration = new HandlebarsConfiguration {
                FileSystem = files
            };
            var handlebars = Handlebars.Create(handlebarsConfiguration);
            var render     = handlebars.CompileView("views\\someview.hbs");
            var output     = render(model);

            Assert.Equal("Layout: Foo\r\n\r\nBody: Foo", output);
        }
        public ActionResult Index()
        {
            var model = new MyDynamicModel();

            model.Teacher  = "Albus Dumbledore";
            model.Students = new List <Student>();
            model.Students.Add(new Student {
                Name = "Harry Potter"
            });
            model.Students.Add(new Student {
                Name = "Hermione Granger"
            });
            model.Students.Add(new Student {
                Name = "Ron Weasley"
            });

            return(View("Index", model));
        }
 public ActionResult Index(MyDynamicModel model)
 {
     return(View());
 }