simon-dt / gulp-twig

Twig plugin for gulp.js, The streaming build system. Looking for maintainer or collaborators. See wiki
https://github.com/zimmen/gulp-twig/wiki/Looking-for-maintainer-or-collaborator(s)
MIT License
62 stars 33 forks source link

How to exclude files? #33

Closed MickL closed 7 years ago

MickL commented 7 years ago

I want to use twig.js for css-templating. My structure is something like:

html.twig header.twig footer.twig

mainpage.twig customers.twig contact.twig

The first 3 are only partials and i dont want them to get compiled which does gulp.src('./template/**/*.twig'). Is there any easy way to do this? Ofcourse i could put them into a seperate folder. But for example on sass if you name a file with a "_" prefix they wont get compiled. (e.g. _html.twig).

ghost commented 7 years ago

@MickL This question is not gulp-twig.js related. You can use gulp.src('./template/**/[^_]*.twig') and prefix your partials with underscore. However, I prefer to have then in a separate folder.

davidhellmann commented 7 years ago

Hm but the problem is browserSync does not refresh with the [^_] "hack". Partial support would be nice.

ghost commented 7 years ago

@davidhellmann I don't see the problem? You ignore all _ prefixed templates for rendering. browser-sync is a separate task in my setup, it runs parallel and watch all files changes.

olets commented 7 years ago

@davidhellmann **/[^_]*.twig isn't a hack, it's a glob that matches all files in ./template (at any depth) that don't start with an underscore.

@MickL you can also exclude explicitly with something like gulp.src('yes1', 'yes2', '!no1, '!no2')

Check out Gulp for Beginners: Globbing in Node and isaacs' Glob Primer. You can test patterns with Glob online tester