Open johnkazer opened 6 years ago
We're just outputting the raw data as a string. You should use js-stringify:
const benchmarkData = {
"labels": [
"Heating gas"
],
"series": [
180, 70, 50, 40, 23
]
};
res.render('benchmarktool', {
stringify: require('js-stringify'),
benchmark: benchmarkData
});
script
| const energyLabels = !{stringify(benchmark.labels)};
| const pieSeries = !{stringify(benchmark.series)};
We are considering adding something to make this clearer/easier.
Pug Version: 2.0.0-rc.4
Node Version: v9.2.0
Input JavaScript Values
Input Pug
Expected HTML
Actual HTML
Additional Comments
I need to enclose strings in an array with "'xxx'" two inverted commas/apostrophes, in order to get energyLabels = ['Heating Gas'] in my html. This is very unclear from documentation and was not the behaviour I expected - why the need for "' '"?