Closed zakhenry closed 8 years ago
Thank you for your PR.
Can you give us your reasoning behind this feature.
Hi, the feature is basically for layout inheritance. In my case a module provides a basic layout that a developer can override the default layouts/partials if they desire.
Snippet of my metalsmith config file:
.use(layouts({
engine: 'handlebars',
directory: pathConfig.templates,
directoryFallback: __dirname + '/templates',
partials: pathConfig.partials,
partialsFallback: __dirname + '/templates/partials',
exposeConsolidate: (requires) => {
requires.handlebars = handlebars;
}
}))
Note that the fallbacks are in the current module, but the "parent" npm module passes in configuration to pathConfig.partials
which are checked first.
Wouldn't it be more feasible to put this functionality into its own metalsmith-plugin?
Possibly, but only if metalsmith provided a file retrieval api (that all other plugins used) for reading files as plugins like this one read the filesystem directly.
@zakhenry Layout inheritance is already possible with metalsmith-in-place and languages like swig or nunjucks (i.e. languages that support inheritance). Metalsmith-layouts is meant as a (simple) shim for languages that don't support inheritance.
I would like to refrain from complicating metalsmith-layouts by adding features for inheritance, and instead like to point you to metalsmith-in-place which already serves that purpose. Closing, but feel free to keep the discussion going if you feel otherwise.
@ismay I understand the desire to avoid complication, and am happy to have this feature remain shelved, however I disagree that this specific feature is doable with metalsmith-in-place & nunjucks for example. Their template inheritance pattern does not allow for lazy overloading of templates which this pr addresses.
I probably have a very unique case anyway, with the metalsmith configuration residing in a child npm module with it's fallbacks there too.
If anyone else comes across this thread and would like this feature, I have deployed to https://www.npmjs.com/package/@xiphiaz/metalsmith-layouts
Yeah I understand.
I probably have a very unique case anyway, with the metalsmith configuration residing in a child npm module with it's fallbacks there too.
Yeah I think this is beyond what most people use this module for. If we implement it there probably won't be a lot of people that use it, and it could cause confusion. Good idea to publish a fork! 👍
Includes #97 as this PR is depended on it
Closes #97