Skip to main content
Every .html file in Aero is a template. The same syntax — { } expressions, directives, <script is:build> — works in all of them. The difference is where the file lives and what role it plays:

Pages

Every .html file in client/pages/ becomes a route. index.html maps to /, about.html maps to /about. See Routing for dynamic routes and getStaticPaths.
client/pages/about.html

Components

Components are .html files in client/components/. Import one in a <script is:build> block and use it as a custom element:
client/components/greeting.html
client/pages/index.html
Include the .html extension in import specifiers: import greeting from '@components/greeting.html' resolves to client/components/greeting.html.

Props

Pass data to a component via attributes. Use { } for dynamic values:
Inside the component, destructure from Aero.props:
Spread an object with props="{ ...obj }" to pass every key as a separate prop:
Use self-closing syntax (/>) when a component has no slot content. Use opening and closing tags to pass children into its <slot>:

Layouts

Layouts are .html files in client/layouts/ that wrap page content. Use <slot /> to mark where the content goes:
client/layouts/base.html
client/pages/about.html

Nested layouts

A layout can use another layout. Content flows from page to inner layout to outer layout:
client/layouts/docs.html

Named slots

Define named slots with the name attribute. Pages target them with slot:
client/layouts/base.html
client/pages/home.html

Expressions

Wrap any JavaScript expression in single braces to interpolate it into text or attributes:
Text interpolations are HTML-escaped by default. Use raw() for intentional unescaped HTML:

Loops

Use for (or for) with a for…of expression to repeat an element:
Inside the loop body, Aero provides index, first, last, and length as automatic variables.

Conditionals

Use if, else-if, and else as attributes:

Switch / case

Match a value against multiple alternatives:

Wrapperless output with <template>

Put a directive on <template> to emit only the children without a wrapper element:
This works with if, for, and switch. It is especially useful inside <table> or <select> where an extra <div> would be invalid.
All directive attributes also accept a data- prefix for strict HTML spec compliance: for, if, else, etc.