segment-boneyard / metalsmith-templates

A metalsmith plugin to render files with templates.
46 stars 22 forks source link

handlebars-layouts helpers don't work with metalsmith, metalsmith/consolidate might be failing silently #33

Closed ismay closed 10 years ago

ismay commented 10 years ago

I'm using gulpsmith/metalsmith to compile my handlebars templates, and everything is working as expected, with the exception of the https://github.com/shannonmoeller/handlebars-layouts library. All other bits of handlebars functionality seem to be working (partials, custom helpers, etc.), but handlebars-layouts' {{#extend}} block helper isn't processed at all. It turns up untouched in the output (without any errors or exceptions logged):

<!-- example excerpt from dist/index.html -->
{{#extend "footer"}}{{/extend}}

After opening an issue with https://github.com/shannonmoeller/handlebars-layouts/issues/9 and after that https://github.com/pjeby/gulpsmith/issues/6, @pjeby suggested that there might be an error emitted by metalsmith (or consolidate.js) that isn't being handled correctly somewhere:

If you definitely have an error there, the only other possible culprit is the async chaining library Metalsmith uses to chain plugins together: it was recently updated to support synchronous plugins, and it might be that its error trapping semantics have changed.

Might it be that this is the case? I've created a reduced test case that illustrates what's going wrong from my side: https://github.com/superwolff/cape/tree/handlebars-layouts. Could this possibly be a metalsmith/consolidate issue?

ismay commented 10 years ago

After some more testing, I found out that the handlebars-layouts helpers are working when called from the template (./templates/default.html), but not when called from the file that's being compiled (./src/index.html). In fact, none of the handlebars syntax in ./src/index.html is being compiled.

This seems to be the actual problem that I'm running into, instead of just handlebars-layouts not working. Closing (and opened a more specific issue).