Accept a function as options.name#199
Accept a function as options.name#199wiggisser wants to merge 4 commits intogulp-community:masterfrom
Conversation
index.js
Outdated
|
|
||
| opts.filename = file.path; | ||
| if (typeof namefunc === 'function') { | ||
| opts.name = namefunc(file); |
There was a problem hiding this comment.
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.nameto be able to specify the templates name based on the name of the input file