dyer
dyer

Reputation: 284

EJS layout not working in hapi.js

hapi.js docs explain how to use layouts, but when I set things up as described in the docs, the layout is rendered without bringing in the content. The content is rendered correctly (with no layout) when I remove the server layout config.

This app uses vision, which may be playing a role.

server

engines: {
    html: require('ejs')
},
relativeTo: __dirname,
path: 'templates',
layout: true,
layoutPath: 'templates/layouts',
...

route

handler: (request, reply) => {
    reply.view('test')

templates/layouts/layout.html

<html>
    <body>
        {{{content}}}
    </body>
</html>

templates/test.html

<h1>Test!</h1>

Rendered content is simply:

{{{content}}}

How can I get the content to render inside the layout?

Upvotes: 1

Views: 518

Answers (1)

steel
steel

Reputation: 12520

You need to use the EJS syntax instead of the handlebars syntax.

/layouts/layout.html

<%- content %>

Upvotes: 1

Related Questions