Open jvandenrym opened 8 years ago
Good catch, I will investigate this
What is the structure of your templates folder? Are you putting the partials in _urls? I put them in sibling folders.
Fixed it by adding gulp filter plugin and filtering out _.*html files. I put all pages (and subdirs with pages), includes and templates in src/templates hence the filter.
gulp.task('twig',function(){
const twigPartialsFilter = filter(file => !/\/_/.test(file.path));
return gulp.src('templates/**/*.html')
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}}))
.pipe(data(getJsonData))
.pipe(foreach(function(stream,file){
return stream
.pipe(twig())
}))
.pipe(twigPartialsFilter)
.pipe(gulp.dest('../dist/'));
});
@jvandenrym I'm not sure that mulch is supposed to skip over partials when compiling. For example, if you're using mulch to develop a site locally before moving it onto a CMS, you'll need those compiled partials.
But I like your idea of being able to exclude certain files. The simplest way to do this is by changing the globbing pattern in the twig
gulp task – instead of selecting all files, select all files that do not start with your target character and that are not in a folder that start with your target character.
I've added this in https://github.com/nmcteam/mulch/pull/11. Instead of using an underscore, I'm excluding files and directories that start with hyphen (-
)
@jvandenrym don't know if you saw it, but @JoelSutherland said here that the main mulch shouldn't enforce conventions like "files named like this are excluded." Makes sense to me - that way it remains flexible enough for any sort of project.
But sorry, I misunderstood your point before and you're right: everything in /src/templates needs to be run through twig() even if it doesn't get passed into /compiled. Would const twigCompileFilter = filter('src/templates/urls/**/*');
do it?
I noticed that templates are compiled as well ( _default.html, _header.html) when running gulp mulch-compile where it supposed to only compile the pages themselves.
Suppose before compilation could filter them out?