Can't access data inside pug file
giacomoalonzi opened this issue · comments
Hello, i'm trying to import some data from pug-html-loader in this way
{
test: /\.pug$/,
exclude: ['/node_modules/'],
use: ['html-loader', `pug-html-loader?${qs.stringify({
options: {
debug: !isProduction,
pretty: true,
data: {
title: 'hello',
home: require('./src/content/home.json')
}
}
})}`]
},
but when I try to access data inside pug file, for example:
p= data.title
or p= data.home
nothing happen.
Anyone can help me?
Thank you so much
@willyelm thank you for reply, I did it but nothing happened, no data is visualized.
@willyelm ok fixed
I changed this
{
test: /\.pug$/,
exclude: ['/node_modules/'],
use: ['html-loader', `pug-html-loader?${qs.stringify({
options: {
debug: !isProduction,
pretty: true,
data: {
title: 'hello',
home: require('./src/content/home.json')
}
}
})}`]
},
to this
{
test: /\.pug$/,
exclude: ['/node_modules/'],
use: [
'html-loader',
{
loader: 'pug-html-loader',
query: {
pretty: true,
data: {
title: 'hello',
home: require('./src/content/home.json')
}
}
}
]
}
qs.stringify cause the issue.
Thank you :)