Nunjucks: Retrieve Data From Variables In Json File (npm Only)
I posted a similar question recently but did not get enough of a response to understand my problem. It seems like a question that gets asked a lot but never really answered properl
Solution 1:
For anyone that may come across this the solution, add
data_variable: require('../data.json')
to your route in the index.js file for each page of your site that needs data from a json file.
eg.
/* GET view1. */
router.get('/view1', function(req, res) {
res.render('view1.njk', {
data_variable: require('../variables.json')});
});
Post a Comment for "Nunjucks: Retrieve Data From Variables In Json File (npm Only)"