Interfaces

Project

Pages Html

NuGet packageOwin.Framework.Pages.Html
GitHub sourceOwinFramework.Pages.Html

Home |  Readme

[IsLayout] attribute | The OWIN Framework Pages

The [IsLayout] Attribute

Attach this attribute to a class to identify it as a layout.

Example Usage

[IsPage]
[Route("/", Method.Get)]
[UsesLayout("homePageLayout")]
internal class HomePage { }
[IsLayout("homePageLayout", "zone1")]
[ZoneHtml("zone1", "hello-world", "Hello, world")]
internal class HomePageLayout { }

The [IsLayout()] attribute has the following properties you can set.

Name

If you want to refer to your layout by name in other page elements, then you need to provide a unique name here. The name will be scoped by the package it is in, so the name only has to be unique within the package.

If you want to refer to this layout by name from a page element that is in a different package, then you need to prefix the layout name with the package prefix and a colon, for example "layouts:two_column"

ZoneNesting

This property defines the names of the zones within the layout and also how these are nested in child containers.

For example if I set my ZoneNesting property to zone1,zone2 and I chose ul as my container tag, then I will get Html like this:

<ul>
    // Contents of zone1
    // Contents of zone2
</ul>

If I introduce a third zone, group it with zone 2 like this zone1(zone2,zone3) and choose li as my child container tag, then I will get Html like this:

<ul>
    // Contents of zone1
    <li>
        // Contents of zone2
        // Contents of zone3
    </li>
</ul>

You can nest zones as deeply as you want.

If you want the layout to render some different nesting of containers, or render some zones multiple times or any other specific behavior, then you need to make your Layout class class inherit from the built-in Layout class as described in the Layout element documentation