gulp-pug
gulp-pug copied to clipboard
Support per-file `name` option
when using gulp pug like this
return gulp.src('./client/templates/*.pug')
.pipe(data(function(file) {
return {
name: `__${path.basename(file.path, '.pug')}`
};
}))
.pipe(pug({
client: true,
...
}))
the options returned from the gulp-data function are not passed through to the pug.compileClient. Especially, in my usecase, the template name is not set to the filename but to template
I am doing some maintenance on the lib currently. I'll handle this issue as part of it.
The gulp-data plugin is not designed for passing options through your pipeline. The way that this should probably be solved inside gulp-pug is to make the name
option a string or function. If it is a function, call it for each file with the file as the only argument.
I have misunderstood the issue.
My understanding was that gulp-data
could be used to pass the Pug locals, not the options themselves.
Agreed that per-file configuration can be achieved by accepting a function.
@demurgos I had misunderstood it as well until I dug into pug's options
and noticed that @wiggisser was trying to pass the name
option.
So, is there any possibility to derive the template name from the filename then?
Yes
The way that this should probably be solved inside gulp-pug is to make the
name
option a string or function. If it is a function, call it for each file with the file as the only argument.
OK. I could probably provide a pull request for that ...
This library already supports receiving Pug locals from gulp-data
. I'm renaming the issue to better reflect the actual problem.