concept layout in category aurelia

appears as: The layout, layout, layouts, layout, layouts
Aurelia in Action

This is an excerpt from Manning's book Aurelia in Action.

Even the grandest of applications has humble beginnings. The first version of my-books is no different. You’ll start by creating a single page that allows you to view a list of books and add books to that list. The layout of the application will look something like figure 2.1. The entire application is hosted inside the index.html page. The main application component, app.js, includes a book-list component to render a list of books to the view.

We won’t bring view ports into the my-books sample application, but you can read more and check the samples available on the Aurelia site for further information. The next layout tool that Aurelia provides is aptly named layouts. We’ll explore how you can use layouts to define a different page structure for different sections of your website.

Fortunately, layouts make this easy. Layouts allow you to define multiple top-level pages into which views in your application can be rendered. This allows you to design your UI the way that best fits each page in your application. In this section, we’ll reorganize the user interface, associating each of the modules with one of the following layouts:

You define one or more slots in your layout view, and then reference the slots by name in the view associated with your route. To separate the application into the login and main layouts, create a new login screen (module and corresponding route). When the user visits #/login, render the login screen into the login-layout. If the user visits any other route (for example, #/users), render that screen into the main layout. Figure 9.14 shows how layout views fit into Aurelia’s routing system.

Figure 9.14. A /login route is mapped to a login module (view/view-model pair) and associated with the login-layout view. The login view is then rendered inside the login layout into the header and form slots.

The concept of layouts is easiest to understand with examples. Let’s get our hands dirty and restructure the my-books application to make use of layouts. This process involves the following steps: