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

Injecting file with inject results in copying endtag #215

Open
jrrewers opened this issue Jan 5, 2017 · 0 comments
Open

Injecting file with inject results in copying endtag #215

jrrewers opened this issue Jan 5, 2017 · 0 comments

Comments

@jrrewers
Copy link

jrrewers commented Jan 5, 2017

Hi,
in my index.html I have:

<!-- inject:./themes/light/src/partials/header.html -->
<!-- endinject -->

in partials/header.html I have:

<!-- inject:./themes/light/src/components/component1.html -->
<!-- endinject -->

In my gulpfile I inject files in this way:

injectFile =  function (name, component = false) {
        let type;
        component ? type = 'components' : type = 'partials';
        return inject(gulp.src(`./themes/light/src/${type}/${name}.html`), {
            starttag: `<!-- inject:./themes/light/src/${type}/${name}.html -->`,
            transform: function (filePath, file) {
                return file.contents.toString('utf8');
            }
        })
    }

gulp.task('compileLayoutHTML', ['compileHeaderComponents'], () => {
    return gulp.src('./index.html'dex)
        .pipe(injectFile('header'))
        .pipe(gulp.dest('./'));
});

gulp.task('compileHeaderComponents', () => {
    return gulp.src(headerPartial)
        .pipe(injectFile('component1', true))
        .pipe(gulp.dest(`./themes/light/src/partials`))
});

Everything is working as expected, expect I end up with multiple endtags in index.html:

<!-- inject:./themes/light/src/partials/header.html -->
<p>header</p>

<!-- inject:./themes/light/src/components/component1.html -->
<span>component 1</span>
<!-- endinject -->
<!-- endinject -->
<!-- endinject -->
<!-- endinject -->
<!-- endinject -->
<!-- endinject -->

I watch components/ and partials/ for changes and then recompile the whole thing (firstly partials and then index). Every change in component adds 2 new endtags in index.hml. Is there any way I can avoid it?

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