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

How to pass data.json to nunjucks? #19

Open
levipadre opened this issue Feb 28, 2020 · 0 comments
Open

How to pass data.json to nunjucks? #19

levipadre opened this issue Feb 28, 2020 · 0 comments

Comments

@levipadre
Copy link

levipadre commented Feb 28, 2020

Is it possible to pass a json file?
In gulp works like this:

let data = require('gulp-data');
let nunjucksRender = require('gulp-nunjucks-render');

gulp.task('nunjucks', function(done) {
    return gulp.src(paths.src.templates + '/*.njk')
        .pipe(data(function() {
            return require('./data.json') 
        }))
        .pipe(nunjucksRender({
            path: paths.src.templates,
            envOptions: {
                lstripBlocks: true,
                autoescape: true,
                trimBlocks: true
            }
        }))
        .pipe(gulp.dest(paths.pages.base))
    done();
});

Any way in webpack?

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