How layouts work in @fastify/view
mainLayouts are supported for EJS, Handlebars, Eta, and doT. When a layout is used, the request template is rendered first, and then the layout template is rendered with the resulting HTML injected into the body variable.
Important: Global layouts (set via configuration) and providing a layout during a specific render call are mutually exclusive. You cannot mix them.
Engine-specific body syntax:
- EJS:
<%- body %> - Handlebars:
{{{ body }}} - ETA/doT:
<%~ it.body %>
<!-- layout.ejs: -->
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<%- body %>
<br/>
</body>
</html>