Skip to content
This repository has been archived by the owner on Apr 30, 2019. It is now read-only.

Latest commit

 

History

History
63 lines (42 loc) · 2.06 KB

Layouts.md

File metadata and controls

63 lines (42 loc) · 2.06 KB

Layout

Aero is designed to work with single-layout websites that can be easily ajaxified. If you need multiple layouts you can create multiple Aero apps with different root directories in one node instance.

The default layout.pug is as simple as this:

doctype html
html
	head
		title= app.config.title

	body
		main#content!= content

You can add this file to your layout directory and Aero will instantly load the changes.

Globals

In the example above app refers to the app instance and app.config refers to your config.json file. Therefore app.config.title returns the title defined in your configuration.

content is defined by Aero to insert the page contents. We're not using Jade blocks because they don't work well when you need to ajaxify your site.

The difference between Jade's = and != is that the former escapes the string while the latter will just directly insert it. Since content includes the rendered HTML of the page you need to use != for the page contents.

Controller

Layout controllers are very similar to page controllers, the only difference is the function signature:

exports.render = function(request, render) {
	render({
		custom: 'Hello World'
	})
}

It doesn't make sense to define get or post methods for layout controllers which is why the exported function needs to have the generic name render. The response parameter is also dropped and replaced by a special render function as the 2nd parameter.

Layout components follow the same naming convention as pages. If your directory is called layout then it can include the following files:

  • layout.pug
  • layout.styl
  • layout.json
  • layout.js

Pre-defined headers

Every Aero website includes these in your head tag by default and there is no need to add that boilerplate by yourself:

Web manifest

<link rel="manifest" href="manifest.json">

Mobile viewport

<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">