Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actual example of gulp-data use #56

Open
WojoJustin opened this issue Aug 29, 2018 · 0 comments
Open

Actual example of gulp-data use #56

WojoJustin opened this issue Aug 29, 2018 · 0 comments

Comments

@WojoJustin
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant