public void Sidebar_not_defined_renders_default_content()
            {
                var hbsve = new HandlebarsViewEngine();

                hbsve.RegisterSectionsHelpers();
                var handlebars = Handlebars.Create(hbsve.HandlebarsConfiguration);

                var view   = new CompiledView(handlebars.Compile("No section here."), null, null);
                var layout = new CompiledView(handlebars.Compile(source), null, null);

                var controllerContext = new ControllerContext();
                var hbsview           = new HandlebarsView(controllerContext, view, new[] { layout });

                var html = GetHtmlFromView(hbsview);

                Assert.Equal("<p>Default sidebar content...</p>", html);
            }
            public void RenderSection_doesnt_throw_for_undefined_section_when_not_required()
            {
                var hbsve = new HandlebarsViewEngine();

                hbsve.RegisterSectionsHelpers();
                var handlebars = Handlebars.Create(hbsve.HandlebarsConfiguration);

                var view   = new CompiledView(handlebars.Compile("Body not rendered."), null, null);
                var layout = new CompiledView(handlebars.Compile("Name: {{rendersection \"name\" required=false}}."), null, null);

                var controllerContext = new ControllerContext();
                var hbsview           = new HandlebarsView(controllerContext, view, new[] { layout });

                var html = GetHtmlFromView(hbsview);

                Assert.Equal("Name: .", html);
            }
            public void Sidebar_defined_renders_content_and_chrome()
            {
                var hbsve = new HandlebarsViewEngine();

                hbsve.RegisterSectionsHelpers();
                var handlebars = Handlebars.Create(hbsve.HandlebarsConfiguration);

                var view   = new CompiledView(handlebars.Compile("{{#definesection \"sidebar\"}}Sidebar{{/definesection}}"), null, null);
                var layout = new CompiledView(handlebars.Compile(source), null, null);

                var controllerContext = new ControllerContext();
                var hbsview           = new HandlebarsView(controllerContext, view, new[] { layout });

                var html = GetHtmlFromView(hbsview);

                Assert.Equal("<div id=\"sidebar\">Sidebar</div>", html);
            }
            public void DefineSection_can_append()
            {
                var hbsve = new HandlebarsViewEngine();

                hbsve.RegisterSectionsHelpers();
                var handlebars = Handlebars.Create(hbsve.HandlebarsConfiguration);

                var view    = new CompiledView(handlebars.Compile("{{#definesection \"name\"}}From view.{{/definesection}}"), null, null);
                var layout1 = new CompiledView(handlebars.Compile("{{#definesection \"name\" mode=\"append\"}}Appended.{{/definesection}}"), null, null);
                var layout2 = new CompiledView(handlebars.Compile("{{rendersection \"name\"}}"), null, null);

                var controllerContext = new ControllerContext();
                var hbsview           = new HandlebarsView(controllerContext, view, new[] { layout1, layout2 });

                var html = GetHtmlFromView(hbsview);

                Assert.Equal("From view.Appended.", html);
            }