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

Support per-file name option #192

Open
wiggisser opened this issue Feb 3, 2019 · 8 comments
Open

Support per-file name option #192

wiggisser opened this issue Feb 3, 2019 · 8 comments
Assignees

Comments

@wiggisser
Copy link

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

@demurgos
Copy link
Member

demurgos commented May 9, 2019

I am doing some maintenance on the lib currently. I'll handle this issue as part of it.

@demurgos demurgos self-assigned this May 9, 2019
@phated
Copy link
Member

phated commented May 9, 2019

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.

@demurgos
Copy link
Member

demurgos commented May 9, 2019

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.

@phated
Copy link
Member

phated commented May 9, 2019

@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.

@wiggisser
Copy link
Author

So, is there any possibility to derive the template name from the filename then?

@demurgos
Copy link
Member

demurgos commented May 9, 2019

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.

@wiggisser
Copy link
Author

OK. I could probably provide a pull request for that ...

@demurgos
Copy link
Member

demurgos commented May 9, 2019

This library already supports receiving Pug locals from gulp-data. I'm renaming the issue to better reflect the actual problem.

@demurgos demurgos changed the title pug.compileClient does not receive data from gulp-data Support per-file name option May 9, 2019
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

Successfully merging a pull request may close this issue.

3 participants