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 use gulp-jade-inheritance with gulp-data? #11

Open
ruslanxdev opened this issue Feb 23, 2016 · 3 comments
Open

How to use gulp-jade-inheritance with gulp-data? #11

ruslanxdev opened this issue Feb 23, 2016 · 3 comments

Comments

@ruslanxdev
Copy link

Hi!
I know how to use gulp-jade with gulp-data.
https://github.com/phated/gulp-jade#use-with-gulp-data
http://stackoverflow.com/questions/27313107/gulp-using-gulp-jade-with-gulp-data

But I do not know how to use gulp-jade-inheritance with gulp-data. You have to either compile all pages when you change the JSON file, or search for and compile the pages that use this data. Maybe you have any ideas?

Here is my code:

gulp.task('jade', function(){
    return gulp.src(['src/jade/**/*.jade'])
        .pipe(plumber(function(error) {
            gutil.log(gutil.colors.red('Error: ' + error.message));
            this.emit('end');
        }))
        .pipe(changed('public', {extension: '.html'}))
        .pipe(cached('jade'))
        .pipe(jadeInheritance({basedir: 'src/jade'}))
        .pipe(data(function(file) {
            return JSON.parse(fs.readFileSync('./src/jade/data.json'));
        }))
        .pipe(filter(function (file) {
            return !/\/_/.test(file.path) && !/^_/.test(file.relative);
        }))
        .pipe(jade({
            pretty: '\t'
        }))
        .pipe(gulp.dest('public'))
        .pipe(livereload());
});
gulp.task('jade:all', function(){
    return gulp.src(['src/jade/**/*.jade'])
        .pipe(plumber(function(error) {
            gutil.log(gutil.colors.red('Error: ' + error.message));
            this.emit('end');
        }))
        .pipe(data(function(file) {
            return JSON.parse(fs.readFileSync('./src/jade/data.json'));
        }))
        .pipe(filter(function (file) {
            return !/\/_/.test(file.path) && !/^_/.test(file.relative);
        }))
        .pipe(jade({
            pretty: '\t'
        }))
        .pipe(gulp.dest('public'))
        .pipe(livereload());
});

Thanks!

@juanfran
Copy link
Owner

I'm not very sure, I've to test it, but maybe using https://github.com/jgable/gulp-cache and using the data.json and the filte content to generate the key. I'll try to test it this week.

@juanfran
Copy link
Owner

I've testes with gulp-cache and its works with differents data.json, if all the jade files use the same data.json I think it should be compiled all again... sorry I don't have more ideas. Anyway, your code should work, are you having any errors?

@ruslanxdev
Copy link
Author

Thank you, I have not found a solution to his problem. Everything works, but I was not able yet to optimize this process.

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

2 participants