Skip to content
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

Feature: Support for Nested Partials #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vincenttaglia
Copy link
Contributor

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!

@colbyfayock
Copy link
Owner

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

@colbyfayock
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants