html-webpack-partials-plugin icon indicating copy to clipboard operation
html-webpack-partials-plugin copied to clipboard

Feature: Support for Nested Partials

Open vincenttaglia opened this issue 4 years ago • 2 comments

With this PR I have implemented support for nested partials.

I got this to work by passing child partial information in the options object, and iterating through all nested partials, before injecting the partial in the top level template.

This is an example plugin configuration for webpack.config.js:

new HtmlWebpackPlugin({
    title: "Index",
    template: path.join(__dirname, "./src/templates/index.html"),
    filename: "index.html",
    minify: false,
    inject: false,
}),
new HtmlWebpackPartialsPlugin({
    path: path.join(__dirname, './src/partials/partial.html'),
    location: 'partial',
    template_filename: "index.html",
    options: {
        subPartials: [
            {
                path: path.join(__dirname, './src/partials/nested_partial.html'),
                location: 'nested-partial',
                options: { },
            },
        ]
    },
}),

And you can keep nesting more partials in the options of other nested partials!

vincenttaglia avatar Nov 28 '20 20:11 vincenttaglia

hey @vincenttaglia to start off, similar to the other one, can we add an example and test?

colbyfayock avatar Dec 12 '20 02:12 colbyfayock

hey @vincenttaglia did you still want to move forward on this? if so can you add an example and tests like your last one?

colbyfayock avatar Mar 19 '21 13:03 colbyfayock