Monday, 15 May 2017

How to get multiple content areas in hapi.js layouts?

I would like to define information in a template that is rendered in the containing layout using ejs in hapi.js. For example:

layout.html

<html>
    <head>
        <title><%- contentFor('title') %></title>
    </head>
    <body>
        <%- content %>
    </body>
</html>

index.html

contentFor('title', 'My title')

<h1>My content</h1>

It is important to me that however it works, the different layout contents are defined in the template, not passed in at the route level. Is this possible?



via dyer

No comments:

Post a Comment