gulp-pug
gulp-pug copied to clipboard
Accept a function as options.name
Accept a function as options.name
to be able to specify the templates name based on the name of the input file
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.
I was expecting to avoid the temporary variable or possibly undefined options
with:
if (typeof opts.name === "function") {
const name = opts.name(...);
compiled = pug.compileClient(contents, Object.assign({}, opts, {name}));
} else {
compiled = pug.compileClient(contents, opts);
}
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.