Closed swey closed 7 years ago
So you are using .data()
to specify global data? Otherwise @root
would be empty anyway, right?
@root
references to the most upper data level and it worked quite well in the old estatico version, where the data was assigned with dataEach
based on file.data
.
But in the latest version dataEach
was removed and actually the main data object is empty, only file.data
is filled. But the file.data
context is only an alternative context of gulp-hb
and is not intent to be the main data source.
So dataEach
did just assign everything from file.data
into the @root
? Judging from the new docs, it doesn't seem to be possible to expose file-specific data globally anymore.
For more information on @root
see: http://handlebarsjs.com/reference.html
In the gulp-hb
task the data of the handlebars template needs to be set via .hb({data: {})
in the object or with the extra method .hb().data({})
, at the moment no data is set at all (only in the alternative file.data
context).
I saw that you asked some questions in the gulp-hb
repo some time ago, where they told you to use dataEach
and that made the job. I tried to fix it in a different way and to add dataEach
again, but I'm no gulp expert at all, so it did not work so far.
I don't think we can solve this. .hb({data: {})
would have to be called outside of the stream and .hb().data({})
does not provide us access to the currently streamed file.
I think you will have to ask gulp-hb
to add an additional option for this (similar to dataEach
, having the currently streamed file as an argument) and pass the data to templateOptions.data.root
or context
PR openend in gulp-hb
: https://github.com/shannonmoeller/gulp-hb/pull/48
Version 6.0.0 of gulp-hb fixes the problem 🎉
Will create a PR as soon the latest version is listed on npm
The context of the pages is wrong, because
@root
is empty and does not include any data. The data is only accessible as file-specific data via@file.data
.A reason could be that
dataEach
is not supported bygulp-hb
/handlebars-wax
anymore: https://github.com/unic/estatico/blob/develop/gulp/html/default.js#L187Also see: https://github.com/shannonmoeller/gulp-hb/tree/v5.0.0#template-context