Open WojoJustin opened 6 years ago
I've only been able to make this work by providing a function to process a JSON file directly through the twig initialization in gulp:
return gulp.src(paths.src) .on('error', handleErrors) .pipe(twig({ data: { "tables": function(file) { var dataPath = path.resolve(config.root.src, config.tasks.html.src, config.tasks.html.dataFile); var data = JSON.parse(fs.readFileSync(dataPath, 'utf8')); return data; } } })) .on('error', handleErrors) .pipe(gulp.dest(paths.dest))
running:
.pipe(data(function (file) { return JSON.parse(fs.readFileSync('./examples/' + path.basename(file.path) + '.json')); })) .pipe(twig())
has not worked at all. gulp-data has been returning the actual gulp information and not my json file data. There's also no way to configure how this data is defined in the template.
gulp-data
I've only been able to make this work by providing a function to process a JSON file directly through the twig initialization in gulp:
running:
has not worked at all.
gulp-data
has been returning the actual gulp information and not my json file data. There's also no way to configure how this data is defined in the template.