-
Notifications
You must be signed in to change notification settings - Fork 80
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
Accept a function as options.name #199
base: master
Are you sure you want to change the base?
Conversation
index.js
Outdated
@@ -16,6 +17,9 @@ module.exports = function gulpPug(options) { | |||
const data = Object.assign({}, opts.data, file.data || {}); | |||
|
|||
opts.filename = file.path; | |||
if (typeof namefunc === 'function') { | |||
opts.name = namefunc(file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should move this into the opts.client
conditional because it is only used for client compilation. We might as well avoid extra loops when it doesn't effect the output.
The type definitions should also be updated, but you no longer can directly extend Pug's options because on the pug side, name must be a string. You can leave it to me if you are not familiar with Typescript, I'll fix it before merging. |
fixes #192 |
The current code should work fine. My main issue was with the variable name, you now check its type so it's less confusing.
Thanks for the PR and tests. I'll add a changelog entry, update the type definitions, documentation and rebase on top of #201. It will be published to npm soon (probably with #200). |
+1 Any chance this will be released/published soon? |
@wiggisser @lcavadas if either of you want to rebase this PR on the latest changes and update the type definitions, I'm happy to get it released. |
Accept a function as
options.name
to be able to specify the templates name based on the name of the input file