ericf / express-handlebars

A Handlebars view engine for Express which doesn't suck.
BSD 3-Clause "New" or "Revised" License
2.31k stars 384 forks source link

Resolve layout partials without fully compiling #197

Closed wheresrhys closed 7 years ago

wheresrhys commented 7 years ago

I'm using express handlebars mainly on server architecture, but would also like to use its partial & helper registration in serverless architecture. Unfortunately, the resources available in AWS Lambda aren't enough to scan all dependency directories to find partials, and then compile and render the template.

The layout used by my express apps requires many partials from dependencies. What I would really like to do is to pre-resolve these partials, and generate a new template which can be used in Lambda, so that Lambda doesn't have to resolve the partials for the layout, and can concern itself just with the partials needed for the body of the page.

i.e

layout.html

<html>
{{>my-dependency/partial}}
<body>
{{body}}
</body>
</html>

my-dependency/partial.html

<head>
 <link ...>
</head>

desired output

<html>
<head>
 <link ...>
</head>
<body>
{{body}}
</body>
</html>

Can you advise if there's some way I could hack in to the template resolution & compilation to achieve this?

wheresrhys commented 7 years ago

Would precompiled: true be the answer?