shannonmoeller / gulp-hb

A sane Gulp plugin to compile Handlebars templates. Useful as a static site generator.
http://npm.im/gulp-hb
MIT License
147 stars 14 forks source link

Reintroduce `dataEach` or similar. #49

Closed shannonmoeller closed 7 years ago

shannonmoeller commented 7 years ago

The dataEach option was dropped when @root and @file were introduced. Current solution of using @file.data seems less than ideal.

https://github.com/shannonmoeller/gulp-hb/issues/10#issuecomment-275220220

shannonmoeller commented 7 years ago

@backflip Thank you for PR #48, but I wonder if we can address this differently. I'm not a fan of the hook that would make @root equivalent to @file.data in some circumstances. I think I'd rather add another @ alias like @local or @data.

Would something like that be sufficient to solve the usecase in unic/estatico#36?

shannonmoeller commented 7 years ago

I think the real cause of this issue is in handlebars-wax. It is overriding the meaning of @root to be the global data, rather than the object that's passed to the template. If I don't override @root there, this problem goes away and everything will work as expected in estatico.

shannonmoeller commented 7 years ago

This issue was addressed in handlebars-wax and published as v5. I have pulled in this new version to gulp-hb and published as v6.

The value of @root should now be as @swey expected in unic/estatico#36.