Open daveferrara1 opened 7 years ago
Wondering also if I were to use something like
onBeforeSetup: function (Handlebars) {
title: 'test'
},
It does not seem to be available like {{HandlebarsPlugin.title}}
Is there a way to do that?
Hi daveferrara.
The data is simply passed to the template function as explained in the handlebars docs. To access the data within a helper you have two options:
{{myhelper dataInScope}}
orTo bind the data in webpack.config
const data = require("./public/build/manifest.json");
// ...
plugins: [
new HandlebarsPlugin({
data,
helpers: {
myhelper: function () {
// access data
}
}
})
Thank you for the answer 👍
@sagold Thanks.
I've got this in my config:
I can't seem to access the data in an .hbs file. I'd prefer to get at the data in a helper. I am looking to parse that json in a helper and write some script tags.
Do you have an example using
data:
?