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 request: Optional partialResolver #205

Open
Devqon opened this issue Dec 10, 2021 · 1 comment
Open

Feature request: Optional partialResolver #205

Devqon opened this issue Dec 10, 2021 · 1 comment

Comments

@Devqon
Copy link

Devqon commented Dec 10, 2021

Hi,

We use the handlebars-loader in combination with Storybook and plain html/scss, which works awesome!

We want to configure handlebars to optionally resolve partials based on prefixed, and if not passed use the default partial resolver. There is now only an option to override the behavior completely, without fallback.

What we want to achieve:

<!-- custom resolving, search in a directory called 'legacy' -->
{{> legacy.my-partial }}
<!-- should still work (fallback to default resolve) -->
{{> my-partial }}
@thibaudsowa
Copy link

thibaudsowa commented Jun 9, 2023

Hi,

I had the same request and I manage to do this by that ugly thing:

{
    test: /\.(html|handlebars|hbs)$/,
    use: [
        {
            loader: 'handlebars-loader',
            options: {
                partialResolver: function (partial, callback) {
                    callback(undefined, (partial.startsWith('common/') ? path.join(__dirname, 'src', 'partials', partial.replace('common/', '')) : './' + partial) + '.hbs')
                }
            }
        }
    ]
}

In this example, with prefix 'common', partials will be loaded from '/src/partials", without prefix it will follow standard import.

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

No branches or pull requests

2 participants