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

False errors in files, compiled with partials #12

Open
kpobococ opened this issue Jul 7, 2016 · 4 comments
Open

False errors in files, compiled with partials #12

kpobococ opened this issue Jul 7, 2016 · 4 comments

Comments

@kpobococ
Copy link

kpobococ commented Jul 7, 2016

I'm using gulp-file-include to move repetitive parts of my html pages (like page header and footer) to outside files. However, gulp-html does not seem to use the compiled version for its validation, because it gives me errors about missing title element within head (which is inside one of the partials).

Here's a shortened version of my gulpfile.js:

var gulp            = require('gulp');
var gulpFileInclude = require('gulp-file-include');
var gulpHtml        = require('gulp-html');

gulp.task('html', function () {
    return gulp.src('src/*.html')

        // Include partials
        .pipe(gulpFileInclude({
            prefix:   '<!-- partial:',
            suffix:   ' -->',
            basepath: 'src/partials/',
            context:  {
                'compileJs': false
            }
        }))

        // Validate
        .pipe(gulpHtml())
        .pipe(gulp.dest('dist/'));
});

Am I missing something or is it a bug?

@XhmikosR
Copy link
Member

It's not supported. PRs welcome.

@paulshryock
Copy link

However, gulp-html does not seem to use the compiled version for its validation, because it gives me errors about missing title element within head (which is inside one of the partials).

@kpobococ I know this is an old issue, but I ran into it today while using gulp-html for the first time. I solved it by moving validation to a separate task.

gulp.task('html', function () {
    return gulp.src('src/*.html')
        // Build HTML here using something like a static site generator
        .pipe(gulp.dest('dist/'));
});

gulp.task('validate', function () {
    return gulp.src('dist/*.html')
        .pipe(validator())
        .pipe(gulp.dest('dist/'));
});

To me it seems like this defeats the purpose of Gulp streams... you should just be able to .pipe the compiled HTML into the validator(). For whatever reason, it seems to only work in a separate task.

@ZhangChengLin
Copy link

For whatever reason, it seems to only work in a separate task.

I think he doesn't have a job, nor does he have a job in a separate task, sometimes it only reports running errors.
I tried to change the checked html code to a mess, and he didn't give any hints.
@XhmikosR

@paulshryock
Copy link

True. Most projects I've used this on, I ended up turning it off later when it threw random errors and blocked deployments. Hasn't been super useful.

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

No branches or pull requests

4 participants