Closed 5ulo closed 7 months ago
Hello @5ulo,
thanks for the issue report. I'll try to fix it in a few days.
@5ulo
I can't reproduce the issue.
See the test case.
All @data
variables are accessible inside the loop.
Please create a small repo with reproducible issue.
@webdiscus so I found @root
cant be accessed if you extend page with layout page. Just to clarify the situation:
dir pages
- for example index, home, contact... simply said its everything between <body></body>
dir partials/layout
- contains page layouts (<html>
with #block
)
dir partials/parts
- contains regular partials
So the process in my case is to assign some data (title, body class...) inside index.hbs
then fill the partial and extend to layout. I made a git as you requested
@5ulo thanks for the clarification.
Yes, now I can reproduce it. Obviously this is a bug in the block/partial
helper. I will fix it.
@5ulo
the issue is fixed in the version 3.1.3
.
Thank you!
checked.. is working perfectly.. done .. thank You! Closing :)
@5ulo
you can simplify the config using the references preprocessor
and preprocessorOptions
in plugin options w/o loaderOptions: {...}
:
new HtmlBundlerPlugin({
entry: './src/pages',
data: './src/data.json',
preprocessor: 'handlebars',
preprocessorOptions: {
root: './src/pages',
views: [
'./src/partials',
],
partials: [
'./src/partials',
],
helpers: [
'./src/helpers',
],
},
}),
data
is reference to loaderOptions.data
preprocessor
is reference to loaderOptions.preprocessor
preprocessorOptions
is reference to loaderOptions.preprocessorOptions
The loaderOptions
is the reference to modules.rule[HTMLBundlerLoader].options
.
The plugin adds own HTMLBundlerLoader into Webpack modules automatically.
Current behaviour
In Handlebars when I am inside iteration loop I am not able to access
@root
of the json data. For example inside loop offoo
if I want access{{bar}}
I should do it with{{@root.bar}}
or less comfortable and traversing upwards{{../bar}}
. Traversing is usable but loop inside loop ... will look like{{../../bar}}
and also this is not usable if I want to use thebar
inside partial inside loop..Expected behaviour
Calling
@root.bar
should output the value ofbar
in root of thedata.json
Reproduction Example
Basic
data.json
:Simple loop
nor
Environment
Additional context
This behaviour was on this plugin v2.* too.
@data
variables at handlebars documentation: https://handlebarsjs.com/api-reference/data-variables.html